Usage:
The option “-XX:[+|-]PrintClassHistogram” print a histogram of class instances.
Since:
Starting from JDK 6.
Syntax:
java -XX:[+|-]PrintClassHistogram MainClass
Description:
The flag “PrintClassHistogram” is a diagnostic flag for the hotspot JVM that allows us to enable/disable printing of a class instance histogram after one of the following events:
- Oracle Solaris, Linux, and OS X: Control+Break
- Windows: Control+C (SIGTERM).
Setting this option is equivalent to running the “jmap -histo” command, or the “jcmd pid GC.class_histogram” command, where pid is the current Java process identifier.
The following picture display a sample histogram of a class:
As we can see, the histogram can summary all informations about the heap objects used.
Num: is the order of the instances sorted by bytes
Instances: Number of instances of that class
Bytes: heap allocation of those instances
Class name: The class of the instance, [I represent an array of integers (int[]), [Ljava.lang.String represent a list of String (String[])
Default Value:
This option is disabled by default.
Errors:
None.
Related Posts:
Edit your Comment