ProfilerAttachRunning

Profiling Local Running Process

This page describes attaching to a locally running Java process.

File:attach_running.png

To profile an already running Java application, the profiler needs to attach to the process. The profiler can attach to a local Java 6+ process started by the same user running the IDE. On Microsoft Windows the profiler and profiled application must run on the same JVM architecture (32bit→32bit or 64bit→64bit). Attaching to a running Windows service is not supported.

Note: A step by step guide on profiling live processes is available on the NetBeans Profiler Blog.

Creating Profiler Session

Profiler session for a running Java process can be created using the Attach to Project or Attach to External Process action. The difference from a Profile Project session is that Profile button in the toolbar is replaced by Attach button and the Attach dropdown menu contains Target: section with a Setup Attach to Project... or Setup Attach to Process... action.

Providing Attach Settings

Once the Setup action is invoked, an Attach Settings dialog is displayed. In case the profiler is not fully configured for attach, the dialog is also displayed when clicking the Attach button.

To profile a local running process, the Already running local Java process choice must be selected at the top of the Attach Settings dialog. The rest of the dialog displays a table showing all locally running Java processes available for attach, including their Main class or .jar file and PID. There are the following actions available at the bottom of the dialog:

  • Filter processes action allows to display only Java processes containing the provided substring in their Main class or .jar file.
  • Reload processes action refreshes the table showing all locally running Java processes available for attach. This action needs to be used if the process to attach is started after opening the Attach Settings dialog.
  • Show process details actions opens a dialog displaying additional process information like process parameters and JVM arguments and flags. This is useful when multiple processes with the same Main class are running on the system. The same information is also displayed in a tooltip for each process.
  • Always connect to <Main class> option filters the table to display just the <Main class> processes.

Selecting Local Process

To attach to a Java application for profiling, the process needs to be selected before starting a profiling session. Once a process is selected, it is remembered also for the following sessions (in current IDE session). In case the same process (based on Main class or .jar file and PID) is still running on the system when starting the profiler for the next time, it's picked up automatically by the profiler.

If the Always connect to <Main class> option is selected, the behavior described above is slightly different. Only the Main class or .jar file are remembered (and are persistent between IDE sessions) and if there's exactly one process with this Main class or .jar file running on the system and available for attach, it's picked up automatically by the profiler. If there's more than one such process, the Attach Settings dialog is displayed when starting a profiler session and shows only these processes. In case there's no such process, the Always connect to <Main class> option is cleared.



Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo