"-XX:+PrintGCDetails" - Option for Detailed GC Messages

This section describes the garbage collection logging option, '-XX:+PrintGCDetails', which prints a long detailed message with more details after each garbage collection is done.

In the second test, let's try the "-XX:+PrintGCDetails" garbage collection logging option to see what we will get in the log file:

herong> \progra~1\java\jdk1.8.0\bin\java -Xms2m -Xmx64m -XX:+PrintGCDetails \
   -Xloggc:gc.log GarbageCollection

Step/TotalMemory/FreeMemory/UsedMemory:
1   2031616   698848   1332768
2   3874816   1473392   2401424
3   3874816   425688   3449128
4   8970240   4442016   4528224
...
(Ctrl-C)

herong> more gc.log
Java HotSpot(TM) Client VM (25.45-b02) for windows-x86
   JRE (1.8.0_45-b15), built on Apr 30 2015 12:31:00
Memory: 4k page, physical 3931768k(1445688k free),
   swap 7861660k(3346560k free)
CommandLine flags: -XX:InitialHeapSize=2097152 -XX:MaxHeapSize=67108864
   -XX:+PrintGC -XX:+PrintGCDetails
   -XX:+PrintGCTimeStamps -XX:-UseLargePagesIndividualAllocation
0.100: [GC (Allocation Failure)
   0.100: [DefNew: 889K->64K(960K), 0.0016722 secs]
   889K->755K(1984K), 0.0017865 secs]
1.095: [GC (Allocation Failure)
   1.095: [DefNew: 865K->64K(960K), 0.0040666 secs]
   1.099: [Tenured: 1476K->1540K(1540K), 0.0084915 secs]
   1557K->1540K(2500K), [Metaspace: 1555K->1555K(4480K)], 0.0279583 secs]
2.116: [GC (Allocation Failure)
   2.116: [DefNew: 1061K->127K(1216K), 0.0059764 secs]
   2601K->2580K(3784K), 0.0061521 secs]
3.116: [GC (Allocation Failure)
   3.116: [DefNew: 1171K->127K(1216K), 0.0060344 secs]
   3.122: [Tenured: 3492K->3604K(3604K), 0.0044445 secs]
   3624K->3620K(4820K), [Metaspace: 1556K->1556K(4480K)], 0.0107617 secs]
...

Heap
 def new generation   total 19648K, used 13200K [...
  eden space 17472K,  75% used [...
  from space 2176K,   0% used [...
  to   space 2176K,   0% used [...
 tenured generation   total 43712K, used 32479K [...
   the space 43712K,  74% used [...
 Metaspace used 1561K, capacity 2242K, committed 2368K, reserved 4480K

Notes on the output:

Obviously, "-XX:+PrintGCPrintGCDetails" is a better option than "-XX:+PrintGC". So you should use "-XX:+PrintGCPrintGCDetails" all the time.

Table of Contents

 About This Book

 Heap Memory Area and Size Control

JVM Garbage Collection Logging

 Garbage Collection Demo Program

 Garbage Collection Logging Options

 "-XX:+PrintGC" - GC Logging Option for Short Messages

"-XX:+PrintGCDetails" - Option for Detailed GC Messages

 "-XX:+PrintGCDateStamps" - Calendar Timestamp on GC Messages

 "-XX:+PrintGCApplicationStoppedTime" - Application Pause Durations

 "-XX:+PrintGCApplicationConcurrentTime" - Application Running Durations

 "-XX:+PrintHeapAtGC" - Print Heap Summary per GC

 "-XX:+PrintTenuringDistribution" - Tunuring Distribution

 "-XX:+PrintReferenceGC" - Reference Counts per GC

 "-XX:+PrintFlagsFinal" - Print JVM Options

 Introduction of Garbage Collectors

 Serial Collector - "+XX:+UseSerialGC"

 Parallel Collector - "+XX:+UseParallelGC"

 Concurrent Mark-Sweep (CMS) Collector - "+XX:+UseConcMarkSweepGC"

 Garbage First (G1) Collector - "+XX:+UseG1GC"

 Object References and Garbage Collection

 Garbage Collection Performance Test Program

 Performance Tests on Serial Collector

 Performance Tests on Parallel collector

 Performance Tests on Concurrent collector

 Performance Tests on G1 collector

 Garbage Collection Performance Test Summary

 Archived Tutorials

 References

 Full Version in PDF/EPUB