PSYoungGen Collector Using Tenuring Age

This section demonstrates that the PSYoungGen Collector uses Tenuring Age to perform Young generation GC. But it does not maintain the object age distribution list.

Does the PSYoungGen collector use Tenuring Age Distribution? Let's use our second test program, GarbageCollection2.java to find out:

C:\herong>java -Xms240m -Xmx240m -XX:NewRatio=1 -XX:SurvivorRatio=1
   -XX:+UseParallelGC -Xlog:gc=debug,gc+heap=debug,gc+age=trace
   GarbageCollection2

[0.013s][debug][gc,heap] Minimum heap 251658240  Initial heap 251658240
                         Maximum heap 251658240
[0.015s][info ][gc     ] Using Parallel
Step/TotalMemory/FreeMemory/UsedMemory:
1   209715200   184304096   25411104
...
16   209715200   168575216   41139984
[debug][gc,heap] GC(0) Heap before GC invocations=1 (full 0): PSYoungGen
                        total 81920K, used 40175K [...
[debug][gc,heap] GC(0)   eden space 40960K, 98% used [...
[debug][gc,heap] GC(0)   from space 40960K, 0% used [...
[debug][gc,heap] GC(0)   to   space 40960K, 0% used [...
[debug][gc,heap] GC(0)  ParOldGen       total 122880K, used 0K [...
[debug][gc,heap] GC(0)   object space 122880K, 0% used [...

[debug][gc,age ] GC(0) Desired survivor size 41943040 bytes,
                       new threshold 7 (max threshold 15)

[info ][gc,heap] GC(0) PSYoungGen: 40175K->16272K(81920K)
[info ][gc,heap] GC(0) ParOldGen: 0K->16K(122880K)
[info ][gc] GC(0) Pause Young (Allocation Failure) 39M->15M(200M) 10.897ms

[debug][gc,heap] GC(0) Heap after GC invocations=1 (full 0): PSYoungGen
                        total 81920K, used 16272K [...
[debug][gc,heap] GC(0)   eden space 40960K, 0% used [...
[debug][gc,heap] GC(0)   from space 40960K, 39% used [...
[debug][gc,heap] GC(0)   to   space 40960K, 0% used [...
[debug][gc,heap] GC(0)  ParOldGen       total 122880K, used 16K [...
[debug][gc,heap] GC(0)   object space 122880K, 0% used [...

The log messages of GC(0) confirm that the PSYoungGen collector does use tenuring age to control when to promote live objects in "from" space to "tenured" generation, see "Desired survivor size 41943040 bytes, new threshold 7 (max threshold 15)" log message.

But the PSYoungGen collector does not maintain the object age distribution list as we saw for the Serial collector.

Continue to GC(1):

...
55   209715200   151319312   58395888
[debug][gc,heap] GC(1) Heap before GC invocations=2 (full 0): PSYoungGen
                        total 81920K, used 57011K [...
[debug][gc,heap] GC(1)   eden space 40960K, 99% used [...
[debug][gc,heap] GC(1)   from space 40960K, 39% used [...
[debug][gc,heap] GC(1)   to   space 40960K, 0% used [...
[debug][gc,heap] GC(1)  ParOldGen       total 122880K, used 16K [...
[debug][gc,heap] GC(1)   object space 122880K, 0% used [...

[debug][gc,age ] GC(1) Desired survivor size 41943040 bytes,
                       new threshold 7 (max threshold 15)

[info ][gc,heap] GC(1) PSYoungGen: 57011K->30576K(81920K)
[info ][gc,heap] GC(1) ParOldGen: 16K->16K(122880K)
[info ][gc] GC(1) Pause Young (Allocation Failure) 55M->29M(200M) 10.032ms

[debug][gc,heap] GC(1) Heap after GC invocations=2 (full 0): PSYoungGen
                        total 81920K, used 30576K [...
[debug][gc,heap] GC(1)   eden space 40960K, 0% used [...
[debug][gc,heap] GC(1)   from space 40960K, 74% used [...
[debug][gc,heap] GC(1)   to   space 40960K, 0% used [...
[debug][gc,heap] GC(1)  ParOldGen       total 122880K, used 16K [...
[debug][gc,heap] GC(1)   object space 122880K, 0% used [...

As you can see "from" usage grew from 39% to 74% and nothing promoted to "tenured" generation. So 39% objects survived from the previous GC stayed in "from" and become "age 2". 35% new objects survived in the GC got promoted from "eden" to "from" as "age 1". However, the PSYoungGen collector did not generate any log messages on object age distribution as we saw for the Serial collector

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