Search code examples
javagarbage-collection

Why aren't there more pauseless GC's


All the GC's I know except Azul are somewhat concurrent, but have at least some small stop-the-world component. Why aren't there more GC's like Azul?

Did Azul patent their technology to the extent that it's not possible to do?

Or do the read/write barriers needed for pauseless operation incur so much overhead that they are impractical for most workloads?


Solution

  • ZGC

    Starting from Java 11, there is a new Z Garbage Collector (ZGC) available for Linux/x64 JDK (Windows/macOS since Java 14):

    The Z Garbage Collector, also known as ZGC, is a scalable low latency garbage collector designed to meet the following goals:

    • Pause times do not exceed 10ms
    • Pause times do not increase with the heap or live-set size
    • Handle heaps ranging from a few hundred megabytes to multi terabytes in size

    You can enable ZGC by specifying the following JVM arguments:

    -XX:+UnlockExperimentalVMOptions -XX:+UseZGC
    

    (For Java 15+, -XX:+UnlockExperimentalVMOptions is unnecessary)


    Shenandoah GC

    Also, since Java 12, there is Shenandoah GC available for all platforms. ShenandoahGC has similar characteristics as ZGC but its implementation is different.

    -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC
    

    (For Java 15+, -XX:+UnlockExperimentalVMOptions is unnecessary)

    Shenandoah GC was also backported to Java 11 (11.0.9) and Java 8 (only RedHat builds of JDK 8 include Shenandoah).