Java GC Tutorials - Herong's Tutorial Examples - v1.12, by Herong Yang
Usage Report on Heap Memory Areas
This section provides explanations of the usage report on heap memory areas generated by the '-Xlog:gc+heap=debug' log option.
If we want to know the heap memory is divided into different areas, we can take a look at the heap usage report printed by the "-Xlog:gb+heap=debug" log option.
Rerun GarbageCollection.java with the "-Xlog:gb+heap=debug" option for a few seconds, and review the first "Heap after GC ..." messages:
herong> java -Xms10m -Xmx10m -XX:+UseSerialGC -Xlog:gc+heap=info \ GarbageCollection ... [debug][gc,heap] GC(0) Heap after GC invocations=1 (full 0): def new generation total 3072K, used 319K [... [debug][gc,heap] GC(0) eden space 2752K, 0% used [... [debug][gc,heap] GC(0) from space 320K, 99% used [... [debug][gc,heap] GC(0) to space 320K, 0% used [... [debug][gc,heap] GC(0) tenured generation total 6848K, used 739K [... [debug][gc,heap] GC(0) the space 6848K, 10% used [... [debug][gc,heap] GC(0) Metaspace used 2268K, capacity 6149K, committed 6400K, reserved 1056768K [debug][gc,heap] GC(0) class space used 287K, capacity 672K, committed 768K, reserved 1048576K ...
Here is how we can read the heap usage report:
Note that when the heap size is specified as 10 MB by -Xms10m -Xmx10m, the JVM is automatically gave 3072K to the "new" generation, and 6848K to the tenured generation. It's about 30% for the "new" generation, and 70% for the tenured generation.
Table of Contents
Heap Memory Area and Size Control
JVM Garbage Collection Logging
Introduction of Garbage Collectors
►Serial Collector - "+XX:+UseSerialGC"
GC Log Message Format for Serial Collector
GC Log Message Examples of Serial Collector
Log Message Types from Serial Collector
Serial Collector Stops Application for Minor/Major GC
►Usage Report on Heap Memory Areas
Default NewRatio - Old vs. New Generation
"-XX:NewRatio" - Ratio of Tenured and "new" Generation
"-XX:SurvivorRatio" - Ratio of Eden and Survivor Space
Serial GC Tracing - Tight Heap
Serial GC Tracing - Tight Heap (Part 2)
Serial GC Tracing - Tight Heap (Part 3)
Serial GC Tracing - Plenty of Heap
Serial GC Tracing - Aged Live Objects
Serial GC Tracing - Tenuring Threshold
"-XX:TargetSurvivorRatio" - Second Tenuring Condition
Serial GC Tracing - Tenuring Threshold Controlled
"-XX:+NeverTenure" and "-XX:+AlwaysTenure" Working
Minor GC Triggering Condition of Serial Collector
Parallel Collector - "+XX:+UseParallelGC"
Concurrent Mark-Sweep (CMS) Collector - "+XX:+UseConcMarkSweepGC"
Garbage First (G1) Collector - "+XX:+UseG1GC"
The Z Garbage Collector (ZGC) - "+XX:+UseZGC"
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