Parallel Collector Changing NewRatio and SurvivorRatio

This section demonstrates that the Parallel Collector changes the NewRatio and the SurvivorRatio dynamically, even they are specified in command line.

While testing the Parallel collector, I also noticed that it changes the NewRatio and the SurvivorRatio dynamically, even they are specified in command line. For example:

herong> java -Xms1200m -Xmx1200m -XX:NewRatio=1 -XX:SurvivorRatio=1 \
    -XX:+UseParallelGC -Xlog:gc=debug,gc+heap=debug GarbageCollection2

[debug][gc,heap] Minimum heap 1258291200  Initial heap 1258291200
                  Maximum heap 1258291200
[info ][gc     ] Using Parallel
Step/TotalMemory/FreeMemory/UsedMemory:
1   1048576000   1019201200   29374800
...
172   1048576000   839891968   208684032
[debug][gc,heap] GC(0) Heap before GC invocations=1 (full 0): PSYoungGen...
[debug][gc,heap] GC(0)   eden space 204800K, 99% used [...
[debug][gc,heap] GC(0)   to   space 204800K, 0% used [...
[debug][gc,heap] GC(0)  ParOldGen       total 614400K, used 0K [...
[debug][gc,heap] GC(0)   object space 614400K, 0% used [...

[info ][gc,heap] GC(0) PSYoungGen: 203793K->35808K(409600K)
[info ][gc,heap] GC(0) ParOldGen: 0K->8K(614400K)
[info ][gc     ] GC(0) Pause Young (Allocation Failure)
                       199M->34M(1000M) 11.262ms

[debug][gc,heap] GC(0) Heap after GC invocations=1 (full 0): PSYoungGen...
[debug][gc,heap] GC(0)   eden space 204800K, 0% used [...
[debug][gc,heap] GC(0)   from space 204800K, 17% used [...
[debug][gc,heap] GC(0)  ParOldGen       total 614400K, used 8K [...
[debug][gc,heap] GC(0)   object space 614400K, 0% used [...
   -- NewRatio almost respected as 1: 614400K/3*204800K
   -- SurvivorRatio respected perfectly as 1: 204800K/204800K

...
964   1048576000   802244880   246331120
[debug][gc,heap] GC(4) Heap before GC invocations=5 (full 0): PSYoungGen...
[debug][gc,heap] GC(4)   eden space 204800K, 99% used [...
[debug][gc,heap] GC(4)   from space 204800K, 17% used [...
[debug][gc,heap] GC(4)   to   space 204800K, 0% used [...
[debug][gc,heap] GC(4)  ParOldGen       total 614400K, used 32K [...
[debug][gc,heap] GC(4)   object space 614400K, 0% used [...

[info ][gc,heap] GC(4) PSYoungGen: 240525K->35760K(409600K)
[info ][gc,heap] GC(4) ParOldGen: 32K->40K(614400K)
[info ][gc     ] GC(4) Pause Young (Allocation Failure)
                       234M->34M(1000M) 7.335ms

[debug][gc,heap] GC(4) Heap after GC invocations=5 (full 0): PSYoungGen...
[debug][gc,heap] GC(4)   eden space 204800K, 0% used [...
[debug][gc,heap] GC(4)   from space 204800K, 17% used [...
[debug][gc,heap] GC(4)   to   space 35840K, 0% used [...
[debug][gc,heap] GC(4)   object space 614400K, 0% used [...

965   1048576000   1010867616   37708384
   -- "to" space size dynamically changed from 204800K to 35840K

1163   1048576000   802240432   246335568
[debug][gc,heap] GC(5) Heap before GC invocations=6 (full 0): PSYoungGen...
[debug][gc,heap] GC(5)   eden space 204800K, 99% used [...
[debug][gc,heap] GC(5)   from space 204800K, 17% used [...
[debug][gc,heap] GC(5)   to   space 35840K, 0% used [...
[debug][gc,heap] GC(5)   object space 614400K, 0% used [...

[info ][gc,heap] GC(5) PSYoungGen: 240522K->35808K(578560K)
[info ][gc,heap] GC(5) ParOldGen: 40K->48K(614400K)
[info ][gc     ] GC(5) Pause Young (Allocation Failure)
                       234M->35M(1165M) 9.329ms

[debug][gc,heap] GC(5) Heap after GC invocations=6 (full 0): PSYoungGen...
[debug][gc,heap] GC(5)   eden space 542720K, 0% used [...
[debug][gc,heap] GC(5)   from space 35840K, 99% used [...
[debug][gc,heap] GC(5)   to   space 35840K, 0% used [...
[debug][gc,heap] GC(5)   object space 614400K, 0% used [...
   -- NewRatio changed to: 614400K/578560K = 1.06
   -- SurvivorRatio changed to: 542720K/35840K = 15.14

As you can see from the output, we lost the control of NewRatio and SurvivorRatio. The Parallel collector changed them dynamically.

Table of Contents

 About This Book

 Heap Memory Area and Size Control

 JVM Garbage Collection Logging

 Introduction of Garbage Collectors

 Serial Collector - "+XX:+UseSerialGC"

Parallel Collector - "+XX:+UseParallelGC"

 What Is Parallel Collector

 Parallel Collector GC Log Message Format

 Log Message Types from Parallel Collector

 "--Xlog:gc+task+time=debug" - Print GC Threads

 "-XX:ParallelGCThreads" - # of Threads

 Parallel Collector Stops Application for Minor/Major GC

 PSYoungGen Collector Using Tenuring Age

Parallel Collector Changing NewRatio and SurvivorRatio

 Parallel Collector Adaptive Size Policy

 Adaptive Size Policy Log Messages

 "-Xlog:gc+ergo=trace" - Minor GC Report

 Adaptive Size Policy Changed Survivor Space

 Adaptive Size Policy Changed Eden Space

 Adaptive Size Policy for Best Latency

 Parallel Collector Stopped using Young Generation

 Adaptive Size Policy for Best Throughput

 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