"-XX:SurvivorRatio" - Ratio of Eden and Survivor Space

This section describes the default 'new' ratio (size ratio of tenured vs. 'new' generation).

Can we also control the ratio between "eden" space and survivor spaces? The answer is yes, by using the "-XX:SurvivorRatio" JVM option.

The ratio between "eden" space and survivor spaces is defined as "SurvivorRatio", which is the ratio of the "eden" space and one survivor space.

By default, the "SurvivorRatio" is set to about 8. You can verify this with test results listed in previous tutorials.

Below is another test with "-Xms20m -Xmx20m -XX:NewRatio=1 -XX:SurvivorRatio=6" options. The "new" generation should get 10 MB, which will be divided into: Eden space of 7.5 MB, "from" Survivor space of 1.25 MB and "to" Survivor space of 1.25 MB:

herong> java -Xms20m -Xmx20m -XX:NewRatio=1 -XX:SurvivorRatio=6 \
   -XX:+UseSerialGC -Xlog:gc+heap=info GarbageCollection
...
[debug][gc,heap] GC(0) Heap after GC invocations=1 (full 0):
                        def new generation   total 8960K, used 1279K [...
[debug][gc,heap] GC(0)   eden space 7680K,   0% used [...
[debug][gc,heap] GC(0)   from space 1280K,  99% used [...
[debug][gc,heap] GC(0)   to   space 1280K,   0% used [...
[debug][gc,heap] GC(0)  tenured generation   total 10240K, used 1590K [...
[debug][gc,heap] GC(0)    the space 10240K,  15% used [...

The output confirms that the SurvivorRatio is about 6 (or 7680K/1280K).

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