Attaching a Java Process to Profile - Attaching a Java Process to Profile - 57368

uProf User Guide

Document_ID
57368
Release_Date
2025-06-09
Revision
5.1 English

On Linux Platforms

We can attach the running Java application using --pid option. AMD uProf would be able to collect the profile data and attribute the samples to interpreted Java functions.

GUI

To launch the AMDuProf GUI, go to Home > Welcome page.

  1. Click Profile an Application on the Welcome page.
  2. Click Profile running Process(es) on the Welcome page.
  3. From Select Profile Target, select Process(es).
    Figure 1. Profile Target Java Process
  4. Select the process Id.
  5. From Advanced Options, select Callstack Collection and Callstack Unwind Depth.
  6. Click Start Profile to start the profiling.

CLI

  • To profile a running Java process
    $ ./AMDuProfCLI collect --config tbp -p < java-app-launch-pid> -o /tmp/ -d <duration>
  • To profile running Java process with callstack collection
    $ ./AMDuProfCLI collect --config tbp –g -p < java-app-launch-pid> -o /tmp/ -d <duration>
  • To generate a report:
    $ ./AMDuProfCLI report --src-path <path-to-java-app-source-dir> -i <raw-data-file-path>
Note: Default duration is 30 seconds.

On Windows and FreeBSD Platforms

AMD uProf cannot attach JvmtiAgent dynamically to an already running JVM. Hence, for any JVM process profiled by attach-process mechanism, AMD uProf cannot capture any class information, unless the JvmtiAgent library is loaded during JVM process start up.

To profile an already running Java process, pass -agentpath <path-to-agent-lib>option while launching Java application so that AMD uProf can attach to the Java PID to collect profile data later.

For a 64-bit JVM on Windows and FreeBSD

C:\> java -agentpath:<C:\ProgramFiles\AMD\AMDuProf\bin\ProfileAgents\x64\AMDJvmtiAgent.dll> <java-app-launch-options>

Note the process id (PID) of this JVM instance.

GUI

To launch the AMDuProf GUI, go to Home > Welcome page.

  1. Click Profile running Process(es) on the Welcome page.
  2. From Select Profile Target, select Process(es).
  3. Select the java process Id.
  4. From Advanced Options, select Callstack Collection and Callstack Unwind Depth.
  5. Click Start Profile to start the profiling.