Enabling verbose garbage collection for Oracle Java Hotspot JVM

To enable verbose garbage collection on an Oracle Java Hotspot JVM, add the -verbose:gc flag to the Java HotSpot VM options. Several levels of logging exist, providing more or less output.

The garbage collection time logs can time stamp the various entries with the exact date. Guidewire recommends the following options:

-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:+PrintGCApplicationConcurrentTime 
-XX:+PrintGCApplicationStoppedTime 

These options provide the following:

  • Nature of the garbage collection (minor or full)
  • Amount of memory reclaimed
  • Time elapsed since JVM start or date corresponding to the event, depending on available options
  • Before and after state of the different memory pools (nursery, tenured and permanent)
  • Amount of time the application runs between collection pauses
  • Duration of the collection pause

The level of information can be overwhelming, though it is necessary in some cases.

Add the -Xloggc:file option to redirect output to the specified file.

HPjmeter and GCViewer

HPjmeter and GCViewer are tools that enable you to visually analyze the HotSpot JDK garbage collection logs. Both tools generate:

  • Key metrics about the period (number of minor/major collections, percent of time spent paused, and so forth)
  • Visual representation of the different garbage collections

These tools might require different verbose garbage collection options. Otherwise, HPjmeter or GCViewer might not be able to analyze the corresponding output.

For information on these utility tools, refer to the respective company web sites.

Refer to the following web sites for more information: