## Profiling Using Attach Mode

See Also

The easiest way to profile your application is to use the Profile Main Project command. However, if you want or need to start your application outside of the IDE you can use the attach mode to profile an application. 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 appliction or target JVM
- You want to profile the application without restarting the application

You must use the attach mode in the following cases:

- You want to profile an application running on a remote JVM, such as a remote application server
- You want to profile a Java EE or web application and the target server is not Tomcat, Sun Java System Application Server/GlassFish or JBoss

The Attach mode enables you to attach the profiling tool to an application that is already running, or just about to start on a local or remote machine. Using the attach mode is useful for profiling long-running applications, and in particular for profiling web or enterprise applications running on top of an application server. You can also use the attach mode to profile the code of the application server itself.

### Using the Attach Wizard

Before you can attach to an application, the startup options for the target application or server need to be configured. You use the Attach Wizard to specify the attachment settings for a project. You only need to configure the attachment settings once. The attachment settings are project specific, which means that each project has its own settings. You can go through the Attach Wizard at any time if you want to modify any of the attachment settings.

In the Attach Wizard you specify the type of application and the location. Based on the details that you provide, the Attach Wizard provides you with a set of instructions on how to configure the application or server so that you can attach the profiler.

### Attach Modes

The attach mode you choose depends on the type of profiling data you want to obtain and the details of the target JVM platform. The following table provides an overview of the attach modes:

Attach Mode | Description
--- | ---
Local Direct | Use this mode if you want to obtain profiling data on the startup of a local application. When you use this mode, the target JVM and application wait until you attach the profiler before starting. After you detach from the application, you need to restart the application to start another profiling session.
Local Dynamic (requires JDK 1.6) | Use this mode if you want to obtain profiling data on a local application. To use this mode, the application needs to be running on JDK 1.6. When you use this mode, you can attach to and detach from the application without restarting application.

Remote Direct

Use this mode if you want to obtain profiling data on an application running on a remote JVM. To use this mode, you need to install the Profiler Remote Pack on the target machine. You can download the Profiler Remote Pack at the following URL:

When you use this mode, the remote application starts after the profiler is attached. This mode enables you to obtain profiling data on the startup of the target JVM.

See Also
  Profiling a Running Application
  Selecting a Profiling Task

Legal Notices