Attaching to a Local Application
See Also
You can use the attach mode to profile a local application
when you want or need to start the application outside of the IDE.
For example, you may want to use the attach mode in the following cases:
- Your application needs to be started from the command line or uses a complex launch script
- You want to obtain profiling data on the startup of the application or target JVM
- You want to profile the application without restarting the application
(Dynamic attach mode, requires JDK 1.6 or 1.7)
To attach to a local application, you first need to configure
the attachment settings using the Attach Settings dialog box.
These settings are associated with the project you are profiling.
You only need to configure the attach settings for your project once,
but you can modify the settings at any time in the Attach Settings dialog box.
When you configure the settings for attaching to a local application,
you can choose from the following attachment modes:
- Dynamic. This mode allows you to detach from and attach to the application
at any time without stopping the application. This mode requires JDK 1.6 or 1.7 but does not require
any additional configuration.
- Direct. This mode enables you to obtain profiling data on the startup of the local application.
This mode requires you to modify the startup script and start the application when you want
to attach the profiler.
Perform the following steps to attach to a local application.
- Choose Profile > Attach Profiler (
) from the main menu to open the
Attach Profiler dialog box.
- Select the target application from the Attach To drop-down list at the top of the dialog box.
- Click define to open the Attach Settings dialog box to specify the connection method.
- Select Local as the Attach Method.
- Select either Direct or Dynamic as the connection method.
- Follow the instructions in the Attach Settings dialog box for configuring the application, if necessary.
Click OK.
- In the Attach Profiler dialog box, select a profiling task and any options.
- Click Attach.
To detach from the application:
- Choose Profile > Detach from the main menu or click Detach in the Profiler window.
When you detach from the application, the connection to the target JVM is closed.
When you click Detach, you can choose to stop the application upon detach or allow the application to keep running.
You can re-attach to the application by choosing Profile > Attach Profiler from the main menu.
Modifying the profiling task
Once the connection is established and the profiler is attached to the target application,
you can change the profiling task you are running on the target application without stopping or restarting the application.
To change the profiling task without detaching:
- Choose Profile > Modify Profiling Session (Alt+Shift+F2) from the main menu or click Modify Profiling Session
(
) in the Profiler window.
- Select a new profiling command and adjust any settings.
- Click Run.
The target application is instrumented again without starting or
stopping the application.
- See Also
- Profiling Using Attach Mode
Legal Notices