Java Profiler 7.0 Help
Getting started
Running applications with profiler
About JVMTI and JVMPI (advanced topic)This is an advanced topic. It provides details that you do not normally have to know to profile your applications. Read the following if you want to learn more about profiling capabilities provided by different versions of Java.
What a Java profiling API is
Any profiler, in order to provide profiling results, communicates with JVM by means of a special API. There are two APIs -- JVMPI and JVMTI. These APIs provide different services and influence the range of a profiler's capabilities.
JVMPI, a legacy from older times (Java 1.3, 1.4)
JVMPI (http://java.sun.com/j2se/1.5.0/docs/guide/jvmpi/index.html) was designed for the original classic VM where it worked well. An implementation of JVMPI was created for its replacement, the HotSpot(tm) VM, but it had problems. The root of the issue is that JVMPI wasn't really designed with modern virtual machines in mind. It required events from places that are highly optimized in modern virtual machines. The trouble with events was that they inhibited many optimizations and did not work with all garbage collection implementations. Another big problem was that JVMPI, by its design, did not allow profiling huge memory heaps.
JVMPI was never really standardized. Sun always referred to it as "experimental".
JVMPI is the only profiling interface available in Java 1.3 and 1.4. Java 5 is the last Java version that supports JVMPI, and that is done for compatibility reasons. Java 6 has no JVMPI support.
JVMTI, the new standard API (Java 5 and newer)
Starting with Java 5, a new standardized API was introduced - JVMTI (http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/index.html).
Instead of JVMPI's event-based model, JVMTI utilizes so-called "bytecode instrumentation". This means that profilers, in order to collect profiling information, should modify the bytecode of profiled application, inserting at certain points some supporting bytecode instructions.
Theoretically, this approach shows a lot more potential.
However, the implementation of JVMTI in Java 5 has several drawbacks (they have been solved in Java 6):
- parallel garbage collector is not supported (-XX:+UseConcMarkSweepGC, -Xincgc). Note: JVMPI also has this limitation.
- there is no reasonably fast way to retrieve exact lengths of arrays when capturing a memory snapshot
In addition, there may be some performance issues.
How to choose which API to use
The profiler uses JVMPI for Java 1.3 and 1.4.
The profiler uses JVMTI for Java 5 and newer.
When you profile with the help of IDE integration, the appropriate API will be chosen automatically. If your IDE cannot automatically provide the profiler plugin with the version of Java used to profile the application from within the IDE, JVMPI is assumed. In this case you may select the option "Force profiling with Java 5 API (JVMTI)" - see details for your particular IDE.
J2EE integration wizard generates scripts that automatically choose the appropriate option starting the server with profiler.
If you enable profiling manually, use -Xrunyjpagent for JVMPI
and -agentlib:yjpagent for JVMTI.