Java 8 GC Tutorials - Herong's Tutorial Examples - v1.03, by Dr. Herong Yang
Default NewRatio - Old vs. New Generation
This section describes the default NewRatio which is the ratio of old generation size vs. new generation size.
From the last tutorial, we learned that JVM will automatically divide the heap memory into 2 generations: 30% for the "new" (or Young) generation and 70% for the "old" (or Tenured) generation. In this tutorial, let's run more tests to confirm this:
1. Heap size: 10 MB -
herong> \progra~1\java\jdk1.8.0\bin\java -Xms10m -Xmx10m -XX:+UseSerialGC \ -XX:+PrintGCDetails -XX:+PrintGCTimeStamps GarbageCollection ... Heap def new generation total 3072K, used 2053K [0x04a00000, ... eden space 2752K, 62% used [... from space 320K, 100% used [... to space 320K, 0% used [... tenured generation total 6848K, used 4596K [0x04d50000, ... the space 6848K, 67% used [0x04d50000, 0x051cd3b8, ... Metaspace used 1561K, capacity 2242K, committed 2368K, reserved 4480K
2. Heap size: 20 MB -
herong> \progra~1\java\jdk1.8.0\bin\java -Xms20m -Xmx20m -XX:+UseSerialGC \ -XX:+PrintGCDetails -XX:+PrintGCTimeStamps GarbageCollection ... Heap def new generation total 6144K, used 3057K [0x04800000, ...0) eden space 5504K, 43% used [... from space 640K, 99% used [... to space 640K, 0% used [... tenured generation total 13696K, used 9941K [0x04ea0000, ... the space 13696K, 72% used [0x04ea0000, 0x05855748, ... Metaspace used 1561K, capacity 2242K, committed 2368K, reserved 4480K
3. Heap size: 40 MB -
herong> \progra~1\java\jdk1.8.0\bin\java -Xms40m -Xmx40m -XX:+UseSerialGC \ -XX:+PrintGCDetails -XX:+PrintGCTimeStamps GarbageCollection Heap def new generation total 12288K, used 4753K [0x04800000, ... eden space 10944K, 31% used [... from space 1344K, 99% used [... to space 1344K, 0% used [... tenured generation total 27328K, used 19959K [0x05550000, ... the space 27328K, 73% used [0x05550000, 0x068cde30, ... Metaspace used 1561K, capacity 2242K, committed 2368K, reserved 4480K
4. Heap size: 80 MB -
herong> \progra~1\java\jdk1.8.0\bin\java -Xms80m -Xmx80m -XX:+UseSerialGC \ -XX:+PrintGCDetails -XX:+PrintGCTimeStamps GarbageCollection ... Heap def new generation total 24576K, used 19701K [0x04800000, ... eden space 21888K, 90% used [... from space 2688K, 0% used [... to space 2688K, 0% used [... tenured generation total 54656K, used 0K [0x062a0000, ... the space 54656K, 0% used [0x062a0000, 0x062a0000, ... Metaspace used 1561K, capacity 2242K, committed 2368K, reserved 4480K
The table below is the summary of above tests:
Heap Size New Generation Tenured Generation --------- -------------- ------------------ 10M 3072K 30% 6848K 70% 20M 6144K 30% 13696K 70% 40M 12288K 30% 27328K 70% 80M 24576K 30% 54656K 70%
Conclusion: By default, JVM gives 30% of heap to the "new" generation, and 70% to the tenured generation. Or the default radio of "old" generation size and "new" generation size is 2.33. This ratio is also called NewRatio.
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 - 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" not 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"
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