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:

C:\>\progra~1\java\jdk1.8.0\bin\java -XX:+UseParallelGC    
   -Xms1200m -Xmx1200m -XX:NewRatio=1 -XX:SurvivorRatio=1
   -XX:+PrintGCDetails -XX:+PrintGCTimeStamps 
   -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution
   GarbageCollection2 > output.txt 
(Ctrl-C)

C:\>type output.txt


{Heap before GC invocations=1 (full 0):
 PSYoungGen      total 409600K, used 203779K [...
  eden space 204800K, 99% used [0x2a200000,0x36900ca0,0x36a00000)
  from space 204800K, 0% used [0x43200000,0x43200000,0x4fa00000)
  to   space 204800K, 0% used [0x36a00000,0x36a00000,0x43200000)
 ParOldGen       total 614400K, used 0K [...
  object space 614400K, 0% used [0x04a00000,0x04a00000,0x2a200000)
 Metaspace used 1567K, capacity 2242K, committed 2368K, reserved 4480K
0.204: [GC (Allocation Failure) 
Desired survivor size 209715200 bytes, new threshold 7 (max 15)
[PSYoungGen: 203779K->32024K(409600K)] 
   203779K->32028K(1024000K), 0.0159963 secs] 
Heap after GC invocations=1 (full 0):
 PSYoungGen      total 409600K, used 32024K [...
  eden space 204800K, 0% used [0x2a200000,0x2a200000,0x36a00000)
  from space 204800K, 15% used [0x36a00000,0x38946220,0x43200000)
  to   space 204800K, 0% used [0x43200000,0x43200000,0x4fa00000)
 ParOldGen       total 614400K, used 4K [...
  object space 614400K, 0% used [0x04a00000,0x04a01000,0x2a200000)
 Metaspace used 1567K, capacity 2242K, committed 2368K, reserved 4480K
}
   -- NewRatio almost respected as 1: 614400K/3*204800K
   -- SurvivorRatio respected perfectly as 1: 204800K/204800K

...  
{Heap before GC invocations=5 (full 0):
 PSYoungGen      total 409600K, used 236762K [...
  eden space 204800K, 99% used [0x2a200000,0x369f09b0,0x36a00000)
  from space 204800K, 15% used [0x43200000,0x45146220,0x4fa00000)
  to   space 204800K, 0% used [0x36a00000,0x36a00000,0x43200000)
 ParOldGen       total 614400K, used 16K [...
  object space 614400K, 0% used [0x04a00000,0x04a04000,0x2a200000)
 Metaspace used 1567K, capacity 2242K, committed 2368K, reserved 4480K
0.371: [GC (Allocation Failure) 
Desired survivor size 33030144 bytes, new threshold 6 (max 15)
[PSYoungGen: 236762K->32008K(409600K)] 
   236778K->32028K(1024000K), 0.0100246 secs] 
Heap after GC invocations=5 (full 0):
 PSYoungGen      total 409600K, used 32008K [...
  eden space 204800K, 0% used [0x2a200000,0x2a200000,0x36a00000)
  from space 204800K, 15% used [0x36a00000,0x38942220,0x43200000)
  to   space 32256K, 0% used [0x4da80000,0x4da80000,0x4fa00000)
 ParOldGen       total 614400K, used 20K [...
  object space 614400K, 0% used [0x04a00000,0x04a05000,0x2a200000)
 Metaspace used 1567K, capacity 2242K, committed 2368K, reserved 4480K
}
   -- "to" space size dynamically changed: 204800K to 32256K

{Heap before GC invocations=6 (full 0):
 PSYoungGen      total 409600K, used 236763K [...
  eden space 204800K, 99% used [0x2a200000,0x369f4c20,0x36a00000)
  from space 204800K, 15% used [0x36a00000,0x38942220,0x43200000)
  to   space 32256K, 0% used [0x4da80000,0x4da80000,0x4fa00000)
 ParOldGen       total 614400K, used 20K [...
  object space 614400K, 0% used [0x04a00000,0x04a05000,0x2a200000)
 Metaspace used 1567K, capacity 2242K, committed 2368K, reserved 4480K
0.407: [GC (Allocation Failure) 
Desired survivor size 33030144 bytes, new threshold 5 (max 15)
[PSYoungGen: 236763K->32016K(582144K)] 
   236783K->33060K(1196544K), 0.0154567 secs] 
Heap after GC invocations=6 (full 0):
 PSYoungGen      total 582144K, used 32016K [...
  eden space 549888K, 0% used [0x2a200000,0x2a200000,0x4bb00000)
  from space 32256K, 99% used [0x4da80000,0x4f9c4210,0x4fa00000)
  to   space 32256K, 0% used [0x4bb00000,0x4bb00000,0x4da80000)
 ParOldGen       total 614400K, used 1044K [...
  object space 614400K, 0% used [0x04a00000,0x04b05010,0x2a200000)
 Metaspace used 1567K, capacity 2242K, committed 2368K, reserved 4480K
}
   -- NewRatio changed to: 614400K/582144K = 1.06
   -- SurvivorRatio changed to: 549888K/32256K = 17.05

...

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

Last update: 2018.

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

 "-XX:+PrintGCTaskTimeStamps" - Print GC Threads

 "-XX:ParallelGCThreads=n" - # 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

 "-XX:+PrintAdaptiveSizePolicy" - Minor GC Report

 Adaptive Size Policy Changed Survivor Space

 Adaptive Size Policy Changed Eden Space

 Adaptive Size Policy for Best Latency

 Adaptive Size Policy for Best Throughput

 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

 Garbage Collection Performance Test Summary

 Outdated Tutorials

 References

 Full Version in PDF/EPUB