Profile Image
vishnupriya

What is JVM startup parameter: -XX:+ [+|-]PrintClassHistogram?

What is JVM startup parameter: -XX:+ [+|-]PrintClassHistogram? Have you used this JVM arguement before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvmargument

  • xx-printclasshistogram

  • x-printclasshistogram

  • JVM startup parameter

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

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:

 

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvmargument

  • xx-printclasshistogram

  • x-printclasshistogram

  • JVM startup parameter