Profiling with hprof

[Back]

Java 1.2 introduced an experimental profiling interface, called JVMPI (Java Virtual Machine Profiler Interface). The interface comes with a sample profiling agent, called hprof. Any VM that supports JVMPI should be also able to run hprof.

This agent creates profile data files which can be interpreted after the program terminates. However, the format of the files is still evolving. This version of HPjmeter supports only the formats compatible with JavaSoft reference implementations JDK-1.2.1-A or JDK-1.3.0-C for Solaris(TM) or Windows(R) NT(R)), and in particular:

To run your application with profiling use the following command:
  java ... -Xrunhprof:<options> ApplicationClassName

To profile your applet, use:
  appletviewer ... -J-Xrunhprof:<options> URL

We have found the following hprof options useful:

  1. For performance profiling:
    cpu=samples,thread=y,depth=10,cutoff=0,format=a
  2. For analyzing object allocation or solving memory retention problems:
    heap=all,cpu=samples,thread=y,depth=10,cutoff=0,format=a

To see the complete list of available options, use
  java ... -Xrunhprof:help

The options which affect the collection of profile data supported in this version of HPjmeter are described below:

Note that hprof does not list methods' arguments. In effect, all overloaded methods are represented as just one method.

[Back]

Trademark Acknowledgement
Solaris is a trademark of Sun Microsystems, Inc. in the U.S. and other countries.
Windows NT is a U.S. registered trademark of Microsoft Corporation.