Minor GC Triggering Condition of Serial Collector

This section describes the triggering condition of the Serial collector Minor GC process. The condition is the failure of new object allocation in 'eden'.

We know that when the "eden" space is full, the Serial collector will start a Young (Minor) GC. What is the exact definition of full? Is it 90% full or 100% full?

By looking at GC log messages, I think the exact definition is that "There is not enough free memory in "eden" to allocate the next new object." This is why the Serial collector uses "GC (Allocation Failure)" to label the Young GC event in the log message. "Allocation Failure" in "eden" triggers the Young GC.

If you turn on the "-XX:+PrintHeapAtGC" option, you may see different "eden" usage percentages before different Young GCs.

For example, the following log message shows a Young GC was triggered when the Serial collector failed to allocate the next new object. At that time, "eden" usage was 99%, which is about 10835K used out of 10944K. In other words, the next new object is larger than 109K (or 10944K-10835K).

[debug][gc,heap] GC(1) Heap before GC invocations=1 (full 0): def new ...
[debug][gc,heap] GC(1)   eden space 10944K,  99% used [...
[debug][gc,heap] GC(1)   from space 1344K, 100% used [...
[debug][gc,heap] GC(1)   to   space 1344K,   0% used [...
[debug][gc,heap] GC(1)  tenured generation   total 27328K, used 2025K ...
[debug][gc,heap] GC(1)    the space 27328K,   7% used [...
[info ][gc,heap] GC(1) DefNew: 12285K->1343K(12288K)
[info ][gc,heap] GC(1) Tenured: 2025K->7255K(27328K)
[info ][gc     ] GC(1) Pause Young (Allocation Failure)
                       13M->8M(38M) 9.055ms
...

Here is another example. The following log message shows a Young GC was triggered when the Serial collector failed to allocate the next new object. At that time, "eden" usage was 97%, which is about 39731K used out of 40960K. In other words, the next new object is larger than 1229K (or 40960K-39731K).

[debug][gc,heap] GC(2) Heap before GC invocations=2 (full 0): def new ...
[debug][gc,heap] GC(2)   eden space 40960K,  97% used [...
[debug][gc,heap] GC(2)   from space 40960K,   0% used [...
[debug][gc,heap] GC(2)   to   space 40960K,   0% used [...
[debug][gc,heap] GC(2)  tenured generation   total 122880K, used 39778K ...
[debug][gc,heap] GC(2)    the space 122880K,  32% used [...
[info ][gc,heap] GC(2) DefNew: 40129K->0K(81920K)
[info ][gc,heap] GC(2) Tenured: 39778K->62307K(122880K)
[info ][gc     ] GC(2) Pause Young (Allocation Failure)
                       78M->60M(200M) 11.046ms
...

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