Profile Image

What is Z garbage collector: -XX:+UseZGC?

What is Z garbage collector: -XX:+UseZGC? Have you used this JVM argument before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvm-argument

  • xx-usezgc

  • x-usezgc

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky



You can choose 1 of the 5 available garbage collectors, one of them is ZGC:






ZGC is a scalable and low-latency GC. It is fully available starting Java 15. ZGC performs all expensive operations concurrently, not stopping the execution of application threads for more than 10 ms, which is good for a low-latency apps. It is recommended for server applications, where large heaps are common, and fast application response times are a requirement. One very  important tuning option for ZGC is setting the correct max heap size (-Xmx). ZGC is a concurrent collector, thus a max heap size must be selected such that, 1) the heap can accommodate the live-set of your application, and 2) there is enough headroom in the heap to allow allocations to be serviced while the GC is running. The amount of headroom that is needed very much depends on the allocation rate and the live-set size of the application. In general, the more memory you give to ZGC the better.


Default Value:


Default is Parallel GC.






Arguments related:


TODO link ParallelGCThreads, MaxGCPauseMillis , GCTimeRatio, MinHeapFreeRatio, MaxHeapFreeRatio, Xmx, Xms, UseSerialGC, USeParNewGC, UseG1GC, UseZGC


Related Posts:



If you have additional comments, interesting experiences or even point of disagreement with this JVM argument description, please leave a comment. Your insights will help the entire 10+ million java developer community to develop one standard source of documentation for all the JVM arguments.

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvm-argument

  • xx-usezgc

  • x-usezgc