Java Profiler 7.0 Help
Getting started
Running applications with profiler
Enabling profiling manuallyMost likely, you will not need to configure profiling manually. Please first consider the automated ways to enable profiling in your J2SE, J2EE application or applet.
Step 1: Make profiler agent library accessible to the Java Virtual Machine
The action depends on your OS:
Windows, 32-bit Java |
add <YourKit Java Profiler Home>\bin\win32 to the PATH |
Windows, 64-bit Java |
add <YourKit Java Profiler Home>\bin\win-amd64 to the PATH |
Mac OS X |
add <YourKit Java Profiler Home>/bin/mac to the DYLD_LIBRARY_PATH |
Linux x86, 32-bit Java |
add <YourKit Java Profiler Home>/bin/linux-x86-32 to the LD_LIBRARY_PATH |
Linux AMD64, 64-bit Java |
add <YourKit Java Profiler Home>/bin/linux-amd64 to the LD_LIBRARY_PATH |
Solaris SPARC, 32-bit Java |
add <YourKit Java Profiler Home>/bin/solaris-sparc-32 to the LD_LIBRARY_PATH |
Solaris SPARC, 64-bit Java |
add <YourKit Java Profiler Home>/bin/solaris-sparc-64 to the LD_LIBRARY_PATH |
Solaris x86, 32-bit Java |
add <YourKit Java Profiler Home>/bin/solaris-x86-32 to the LD_LIBRARY_PATH |
Solaris x86, 64-bit Java (AMD64) |
add <YourKit Java Profiler Home>/bin/solaris-x86-64 to the LD_LIBRARY_PATH |
You can find examples of startup scripts for your platform in <YourKit Java Profiler Home>/samples
To make sure that Java can load the profiler agent, you can invoke the following command that
prints a description of agent parameters:
java -agentlib:yjpagent=help (Java 5 and newer)
java -Xrunyjpagent:help (Java 1.3 and 1.4)
Step 2: Add the appropriate VM parameter to the command line of Java application
The parameter depends on Java version.
With Java 5 or newer (JVMTI API) use -agentlib:yjpagent parameter:
E.g., java -agentlib:yjpagent FooClass
With Java 1.3 or 1.4 (JVMPI API) use -Xrunyjpagent parameter:
E.g., java -Xrunyjpagent FooClass
-Xrunyjpagent or -agentlib:yjpagent provides additional options. In most cases there's no need to use them.
The options are comma separated: -Xrunyjpagent[:<option>, ...] or -agentlib:yjpagent[=<option>, ...].
Available options:
disablealloc |
(Java 5 and newer) Do not instrument bytecode with instructions needed for object allocation recording. See Profiling overhead: how to reduce or avoid. |
disablecounts |
(Java 5 and newer) Do not instrument bytecode with instructions needed for CPU tracing. Only CPU sampling will be available. See Profiling overhead: how to reduce or avoid. |
disablej2ee |
(Java 5 and newer) Do not instrument bytecode with instructions needed for J2EE profiling. See Profiling overhead: how to reduce or avoid. |
sampling |
Launch Java application with CPU sampling turned on. Note that you do not have to profile CPU right from the start; instead, in many cases it's better to start or stop measuring at a later moment - from the UI or by using the Profiler API. |
tracing |
Launch Java application with CPU tracing turned on. Note that you do not have to profile CPU right from the start; instead, in many cases it's better to start or stop measuring at a later moment - from the UI or by using the Profiler API. This option cannot be used in combination with 'disablecounts'. |
noj2ee |
Do not perform J2EE high level profiling. This option influences only CPU profiling started with 'sampling' or 'tracing'. Read more about CPU profiling modes. |
alloc |
Launch Java application with object allocation recording started. All objects will be recorded. Note that you do not have to record allocations right from the start; instead, you can start or stop recording later from the Profiler or using Profiler API. This option cannot be used in combination with 'disablealloc'. |
allocadaptive |
Launch Java application with object allocation recording started. As many objects as possible will be recorded, keeping overhead at moderate level. Note that you do not have to record allocations right from the start; instead, you can start or stop recording later from the Profiler or using Profiler API. This option cannot be used in combination with 'disablealloc'. |
monitors |
(Java 5 and newer) Launch Java application with started monitor profiling. Note that you do not have to profile monitor usage right from the start; instead, you can start or stop recording later from the Profiler or using Profiler API. |
usedmem=<percent> |
Automatically capture a memory snapshot when used heap memory
reaches the threshold. |
onexit=memory |
Always capture a memory snapshot on exit. CPU snapshot will be captured automatically if CPU profiling is enabled when the profiled application exits. |
onexit=snapshot |
Capture recorded data (telemetry, and if recorded CPU and monitors profiling results) on exit. This option is automatically used when the profiled application is started from the IDE. |
port=<value>
|
Specify the port that the profiler agent listens on for communication with the Profiler. By default any free port is chosen. |
listen=<ip>:<port>
|
Same as ' |
onlylocal |
Allow only local connections to profiled application |
dir=<directory for snapshots>
|
Specify the directory where snapshots are created. By default, |
quiet |
Suppress diagnostics messages that the profiler agent prints to the console. |
help |
Print a short description of agent parameters. |
Java 5 or newer:
java -agentlib:yjpagent FooClass
java -agentlib:yjpagent=onexit=snapshot,dir=c:\MySnapshots FooClass
java -agentlib:yjpagent=usedmem=70 FooClass
Java 1.3 or 1.4:
java -Xrunyjpagent FooClass
java -Xrunyjpagent:onexit=snapshot,dir=c:\MySnapshots FooClass
java -Xrunyjpagent:usedmem=70 FooClass
Note: Java requires a colon (:) after -Xrunyjpagent,
but an equal sign (=) after -agentlib:yjpagent.