Java 8 GC Tutorials - Herong's Tutorial Examples - v1.03, by Dr. Herong Yang
"-XX:NewRatio" - Ratio of Tenured and "new" Generation
This section describes the default 'new' ratio (size ratio of tenured vs. 'new' generation).
If your application uses lots of short-lived objects, you may want to lower the ratio of Tenured generation over "new" generation by using the "-XX:NewRatio" JVM option.
By default, the "NewRatio" is set to 2.33 based tests we did in the last tutorial. If we specify "-XX:NewRatio=1" and "-Xms40m -Xmx40m", then 40 MB heap will be divided equally to 20 MB for the "new" generation and 20 MB for the tenured generation.
herong> \progra~1\java\jdk1.8.0\bin\java -Xms40m -Xmx40m -XX:NewRatio=1 \ -XX:+UseSerialGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps \ GarbageCollection ... Heap def new generation total 18432K, used 15010K [0x04800000, ... eden space 16384K, 91% used [... from space 2048K, 0% used [... to space 2048K, 0% used [... tenured generation total 20480K, used 20239K [0x05c00000, ... the space 20480K, 98% used [0x05c00000, 0x06fc3ce0, ...
The output confirms that the NewRatio is about 1 (or 20480K/18432K).
If you want to decrease the "new" generation size, you can specify "-XX:NewRatio=3" and "-Xms40m -Xmx40m", which will give us about 30 MB of tenured generation and 10 MB of "new" generation:
herong> \progra~1\java\jdk1.8.0\bin\java -Xms40m -Xmx40m -XX:NewRatio=3 \ -XX:+UseSerialGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps \ GarbageCollection ... def new generation total 9216K, used 4012K [0x04800000, ... eden space 8192K, 48% used [... from space 1024K, 0% used [... to space 1024K, 0% used [... tenured generation total 30720K, used 0K [0x05200000, ... the space 30720K, 0% used [0x05200000, 0x05200000, ...
You can also specify the "new" generation size directly with "-XX:NewSize=..." and "-XX:MaxNewSize=..." options to give a range:
herong> \progra~1\java\jdk1.8.0\bin\java -Xms40m -Xmx40m \ -XX:NewSize=9m -XX:MaxNewSize=11m \ -XX:+UseSerialGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps \ GarbageCollection ... Heap def new generation total 10176K, used 5115K [0x04600000, ... eden space 9088K, 56% used [... from space 1088K, 0% used [... to space 1088K, 0% used [... tenured generation total 29696K, used 0K [0x05100000, ... the space 29696K, 0% used [0x05100000, 0x05100000, ...
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