Garbage-first collector

The garbage-first collector (G1) is a garbage collection algorithm introduced in the Oracle HotSpot Java virtual machine (JVM) 6 and supported from 7 Update 4.

It was planned to replace concurrent mark sweep collector (CMS) in JVM 7 and was made default in Java 9.

Whole-heap operations, such as global marking, are performed concurrently with the application threads, to prevent interruptions proportional to heap or live-data size.

G1 was first introduced as an experimental option in Java SE 6 Update 14,[4] where it can be enabled with the following two command-line parameters: -XX:+UnlockExperimentalVMOptions and -XX:+UseG1GC With JDK 7, G1 was planned to replace CMS in the Hotspot JVM.

[5] G1 compacts sufficiently to completely avoid the use of fine-grain free lists for allocation, which considerably simplifies parts of the collector and mostly eliminates potential fragmentation issues.