
SITES BEGIN (ordered by live bytes) Fri Oct 22 11:52:24 2004 Javac -J-agentlib:hprof=heap=sites Hello.java Only parts of the profiler output file ( ) are shown here. The following is the heap allocation profile generated by running the Java compiler ( javac) on a set of input files. JAVA_TOOL_OPTIONS, but with all environment variables you need to be careful that you don't impact more VMs than you intend. There is also a way to pass Java options with an environment variable. If you were running Java directly, you would not use the -J prefix. With javac, you need to pass Java options with -J. We could create an application, but let's instead use an existing Java application, javac. The msa option only applies to Solaris and causes the Solaris Micro State Accounting to be used. The interval option only applies to cpu=samples and controls the time that the sampling thread sleeps between samples of the thread stacks. Normally the default ( force=y) will clobber any existing information in the output file, so if you have multiple VMs running with HPROF enabled, you should use force=n, which will append additional characters to the output filename as needed. For example, traces might start with 300000. Each type of ID will typically start with a different number than the other ID's. The output in most cases will contain ID's for traces, threads,and objects. The option format=b is considered experimental, this format may changeīy default, heap profiling information (sites and dump) is written out to (ASCII). The -Xrunhprof interface will be removed in a future release. It is not an official product or formal part of the JDK.
#Jprofiler 5.0 code
This is demonstration code for the JVMTI interface and use of BCI, Use of the -Xrunhprof interface can still be used, e.g. The option format=b cannot be used with cpu=old|times. The option format=b cannot be used with monitor=y. Java -agentlib:hprof=heap=sites classname Get heap usage information based on the allocation sites: Java -agentlib:hprof=cpu=samples,interval=20,depth=3 classname Get sample cpu information every 20 millisec, with a stack depth of 3: Option Name and Value Description Defaultįile= write data to file java.hprof HPROF: Heap and CPU Profiling Agent (JVM TI Demonstration Code) The following is the complete list of options that can be passed to HPROF: java -agentlib:hprof=help Java -agentlib:hprof=heap=sites ToBeProfiledClass For example, the following command obtains the heap allocation profile: Java -Xrunhprof ToBeProfiledClassĭepending on the type of profiling requested, HPROF instructs the virtual machine to send it the relevant JVM TI events and processes the event data into profiling information. HPROF can be invoked by one of the following commands: In addition, it can also report complete heap dumps and states of all the monitors and threads in the Java virtual machine.

HPROF is capable of presenting CPU usage, heap allocation statistics, and monitor contention profiles. HPROF has been implemented using the Java Virtual Machine Tool Interface (JVM TI). The binary format file from HPROF can be used with tools such as jhat to browse the allocated objects in the heap.

The data generated can be in textual or binary format and can be used to track down and isolate performance problems involving memory usage and inefficient code. By supplying HPROF options at startup, users can request various types of heap and/or CPU profiling features from HPROF. HPROF is actually a JVM native agent library which is dynamically loaded through a command line option, at JVM startup, and becomes part of the JVM process. The JDK has always provided a simple command line profiling tool called HPROF for heap and CPU profiling.
