Fully featured low overhead profiler for Java EE and Java SE platforms.
Monitoring and profiling solution for Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

Attaching profiler agent to a running JVM

Attach technique allows to load the profiler agent into running JVM. Attached agent has several limitations in functionality in comparison with agent loaded on JVM startup. Attaching simplifies configuration by avoiding special steps to enable profiling, and makes profiling even more "on-demand" than ever.

Attach from Welcome screen

All detected running Java processes are shown in the "Monitor Applications" list on Welcome screen. The colored circle indicates the profiler agent status. When agent is already loaded the circle is green. Orange circle shows that agent is not yet loaded but can be attached.

Attach to the application you want to profile by clicking on its name. Attach from context menu to provide custom agent options.

Attaching is possible to both local and remote applications. Local applications are shown under the node with icon. Applications running on the remote machines are shown under their own nodes with icon. To add a new remote machine click . See remote profiling from user interface to learn more.

If you do not see your application it the list, please read Troubleshoot connection problems. You can use a web browser to check the profiler agent status.

Attach from command line

Run console attach wizard and then connect from Welcome screen.

The attach mode limitations

Unfortunately, the attach mode is not an ultimate solution. The problem is that existing JVMs provide only limited set of profiling capabilities for the attached agents. To get all profiling capabilities, you still have to start the profiled application with the profiler agent instead.

  • The attach mode is only supported for Sun/Oracle/OpenJDK Java (HotSpot) and JRockit.

    Existing IBM VMs do not provide necessary capabilities to let YourKit Java Profiler function in the attach mode. To profile on IBM Java, please start application with the profiler agent. If necessary capabilities are added in future versions of IBM Java, the profiler will support attach mode for IBM Java too.

  • Attach may fail due to insufficient access rights. For example, it may not be possible to attach to a Java EE server running as a Windows service. If attempt to attach fails, start the application with the profiler agent instead.

  • Client JVM can crash in attach mode due to a JVM bug

    Due to a JVM bug 6776659 HotSpot client JVM can crash in attach mode.

    There is no crash for the server JVM: JVM option -server solves the problem.

  • A long pause is possible on first attempt to start CPU tracing or object allocation recording, because classes loaded before the profiler agent has attached need to be instrumented. Depending on application, it can take from several seconds to several tens of seconds, or even a few minutes in worst cases.

    The good news is that there will be no pause on subsequent starts of CPU tracing or object allocation recording for the same running JVM instance.

  • No profiling results for some methods:

    • JVM may not be able to apply bytecode instrumentation to methods of the objects that have been created before the agent attached. Instead, the old, non-instrumented version of the bytecode will keep running for them. This is a limitation of the JVM.
    • Another JVM limitation is that native methods of classes that have loaded before the profiler agent attached cannot be instrumented at all. (There is no problem with classes loaded after the profiler has attached.)

    This means that their calls will be missing in:

    • CPU tracing results (no problem for CPU sampling as it does not depend on bytecode instrumentation)
    • results of probes depending on instrumentation of those methods, in particular, in the "Events" and "Performance Charts" views
  • Exception telemetry is not available