15 Eylül 2023 Cuma

Generational Z Garbage Collector

Giriş
Açıklaması şöyle. Yani ZGC çok büyük heap'leri destekliyor.
ZGC now supports Terabyte-size Java Heaps with permanent sub-millisecond pauses. No important caveats... it may use say 5-10% more memory or 5-10% slower allocation speed, but no more stop-the-world GC pauses and no more heap size limits. 
Açıklaması şöyle
Generational ZGC
The generational hypothesis is the observation that younger objects are much more likely to “die young” than older objects, at least in most cases. That’s why handling objects differently based on their age can be beneficial. Improving the collection of younger objects requires fewer resources and yields more memory.

Even without handling generations, ZGC is quite an improvement in GC pause times, reclaiming memory faster than concurrent threads consume them, at least if enough resources are available. However, all objects are stored regardless of their age, and all of them have to be checked when the GC runs.

With Java 21, the ZGC splits the heap into two logical generations: one for recently allocated objects and another for long-lived objects. The GC can focus on collecting younger and more promising objects more often without increasing pause time, keeping them under 1 millisecond.

The generational ZGC should give us

- Lower risks of allocation stalls
- Lower required heap overhead
- Lower GC CPU impact
All these benefits should come without a significant decrease in throughput compared to non-generational ZGC. Also, there shouldn’t be a need to configure the size of the generations, threads used, or the age limit ourselves.
Örnek
Şöyle yaparız
# Enable ZGC (defaults to non-generational)
$ java -XX:+UseZGC

# Use Generational ZGC
$ java -XX:+UseZGC -XX:+ZGenerational

# Do not use Generational ZGC
$ java -XX:+UseZGC -XX:-ZGenerational



Hiç yorum yok:

Yorum Gönder