G1 collector in JDK 8u40 and 8u60 got a very nice enhancement that might come as a surprise to users when they upgrade to either of these releases.
As we all know that the objects larger than half of the size of the regions are called Humongous objects, and are allocated in special regions called Humongous regions. Up until 8u40, the Humongous regions were not collected during Evacuation pauses, and were collected only at the end of the marking cycle or during Full GCs.
In 8u40, the following G1 enhancement was added: JDK-8027959
: Early reclamation of large objects in G1
This enabled the reclamation of Humongous objects that don't have any reference pointing into it. It added two new experimental JVM options:
- G1ReclaimDeadHumongousObjectsAtYoungGC - Experimental option which is enabled by default. When enabled, G1 reclaims dead objects at every young GC.
- G1TraceReclaimDeadHumongousObjectsAtYoungGC - Experimental option which is disabled by default. When enabled, G1 prints information about the collection of humongous objects at young GCs.
The above change however introduced a regression which is fixed in 8u60. JDK-8069367
: Eagerly reclaimed humongous objects left on mark stack
In 8u60, this enhancement was improved, and the early reclamation now also looks at the Humongous regions that could have a few incoming references. Upon inspection of those incoming references, if G1 finds those references to be stale/dead then that Humongous region is reclaimed. This work was done under the following enhancement request: JDK-8048179
: Early reclaim of large objects that are referenced by a few objects
This change renamed the JVM option G1ReclaimDeadHumongousObjectsAtYoungGC
, and G1TraceReclaimDeadHumongousObjectsAtYoungGC
. It added a new JVM option G1EagerReclaimHumongousObjectsWithStaleRefs
- G1EagerReclaimHumongousObjectsWithStaleRefs - This is an Experimental option, and is enabled by default. When this option is enabled, G1 attempts to reclaim Humongous objects that may have a few stale incoming references, at every young GC.