Let's look at a couple of options to fine-tune ZGC (this chapter covers just a few basic ones). Let's start with the most basic option of setting the max heap size. We can do this by using the following JVM runtime option:
-Xmx<size>
To get the optimal performance, you must set a heap size that can not only store the live set of your application but also has enough space to service the allocations.
ZGC is a concurrent garbage collector. By setting the amount of CPU time that should be assigned to ZGC threads, you can control how often the GC kicks in. You can do so by using the following option:
-XX:ConcGCThreads=<number>
A higher value for the ConcGCThreads option will leave less amount of CPU time for your application. On the other hand, a lower value may result in your application struggling for memory; your application might generate more...