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 the Serial GC 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 -

C:\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 [...
...

2. Heap size: 20 MB -

C:\herong>java -Xms20m -Xmx20m -XX:+UseSerialGC -Xlog:gc+heap=info
   GarbageCollection
...
[gc,heap] GC(0) Heap after GC invocations=1 (full 0):
                 def new generation   total 6144K, used 639K [...
[gc,heap] GC(0)   eden space 5504K,   0% used [...
[gc,heap] GC(0)   from space 640K,  99% used [...
[gc,heap] GC(0)   to   space 640K,   0% used [...
[gc,heap] GC(0)  tenured generation   total 13696K, used 1444K [...
[gc,heap] GC(0)    the space 13696K,  10% used [...
...

3. Heap size: 40 MB -

C:\herong>java -Xms40m -Xmx40m -XX:+UseSerialGC -Xlog:gc+heap=info
   GarbageCollection
...
[debug][gc,heap] GC(0) Heap after GC invocations=1 (full 0):
                        def new generation   total 12288K, used 1343K [...
[debug][gc,heap] GC(0)   eden space 10944K,   0% used [...
[debug][gc,heap] GC(0)   from space 1344K,  99% used [...
[debug][gc,heap] GC(0)   to   space 1344K,   0% used [...
[debug][gc,heap] GC(0)  tenured generation   total 27328K, used 2024K [...
[debug][gc,heap] GC(0)    the space 27328K,   7% used [...
...

4. Heap size: 80 MB -

C:\herong>java -Xms80m -Xmx80m -XX:+UseSerialGC -Xlog:gc+heap=info
   GarbageCollection
...
[debug][gc,heap] GC(0) Heap after GC invocations=1 (full 0):
                        def new generation   total 24576K, used 2688K [...
[debug][gc,heap] GC(0)   eden space 21888K,   0% used [...
[debug][gc,heap] GC(0)   from space 2688K, 100% used [...
[debug][gc,heap] GC(0)   to   space 2688K,   0% used [...
[debug][gc,heap] GC(0)  tenured generation   total 54656K, used 3308K [...
[debug][gc,heap] GC(0)    the space 54656K,   6% used [...
...

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, Serial GC 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

 About This Book

 Heap Memory Area and Size Control

 JVM Garbage Collection Logging

 Introduction of Garbage Collectors

Serial Collector - "+XX:+UseSerialGC"

 What Is Serial Collector

 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

 Garbage Collection Performance Test Summary

 References

 Full Version in PDF/EPUB