Java 10 - Enhanced Garbage Collection

Advertisements

JEP 304 - Garbage-Collector Interface

Before Java 10, GC (Garbage Collector) implementation components were scattered within code base and were not replaceable easily. With Java 10, Garbage-Collector interface is introduced so that alternative GC implementations can be plugged in. It also helps in isolating the code base from different garbage collection implementations. This feature is part of JEP 304.

JEP 307 - Parallel Full GC for G1

Java 9 introduced G1 (Garbage First) garbage collector. G1 avoids full garbage collection but in case of concurrent threads look for collection and memory is not revived fast enough, user experience is impacted. With Java 10, now G1 will use a fall back Full Garbage Collection.

With this change, G1 improves its worst-case latency by using a Full GC in parallel. At present, G1 uses a single threaded mark-sweep-compact algorithm. With JEP 307, a parallel thread will start mark-sweep-compact algorithm. Number of threads can be controlled using following option.

$java -XX:ParallelGCThreads=4
Advertisements