What is ZGC ?
The Z Garbage Collector, also known as ZGC, is a scalable low latency garbage collector designed to meet the following goals:
- Sub-millisecond max pause times
- Pause times do not increase with the heap, live-set or root-set size
- Handle heaps ranging from a 8MB to 16TB in size
ZGC was initially introduced as an experimental feature in JDK 11, and was declared Production Ready in JDK 15.
At a glance, ZGC is:
- Using colored pointers
- Using load barriers
At its core, ZGC is a concurrent garbage collector, meaning all heavy lifting work is done while Java threads continue to execute. This greatly limits the impact garbage collection will have on your application’s response time.
With SDC 5.3.x release, Data Collector supports Java 11 and 17 in addition to Java 8. And hence you can user ZGC if you are using JAVA 17
To enable ZGC just add the following jvm argument -XX:+UseZGC and restart the engine.
You can verify this by review $SDC_LOG/gc.log
❯ cat log/gc.log
1 │ [2022-12-08T16:00:57.285+0530][0.039s] Using The Z Garbage Collector
2 │ [2022-12-08T16:00:58.552+0530][1.306s] GC(0) Garbage Collection (Metadata GC Threshold) 576M(2%
3 │ [2022-12-08T16:01:00.574+0530][3.327s] GC(1) Garbage Collection (Metadata GC Threshold) 3002M(9