Min vs Max vs Soft Memory Limits

Mike Rettig mike.rettig at gmail.com
Fri May 7 16:04:46 UTC 2021


I've been using ZGC with JDK 16 for a few months now and have been pleased
with the performance. I converted a few apps from G1 to ZGC so the heap
could be increased without increasing pause times. ZGC has performed well
in these scenarios.

I've recently been modifying the ZGC options to optimize performance and
minimize the amount of vm option tweaking required for various
environments.  The apps are deployed to a large range of servers with
different amounts of memory.  The apps can be greedy about using memory so
I don't have to worry about uncommitting memory. However, I'd like the ZGC
collector to find an optimal state without giving it all the system memory
at startup.

Here is an example config:

-Xms1024m -XX:SoftMaxHeapSize=1024m -XX:-ZUncommit

I know the app needs at least 1gb. I don't set the max heap because all the
servers are different. The jvm will default the max heap to 25% of the
system memory. I originally didn't set the soft max heap, but I was
surprised when it defaulted to the max heap. How does ZGC handle the soft
heap in this configuration? If the app starts at 1gb but soon needs 2gb
does the soft heap grow with it or does zgc still try to stay below 1gb
since that was the initial value? Would it be better not to set the soft
heap and let it default to the max heap? Does the jvm grow the heap
differently when the soft heap is set to the min heap instead of the max
heap when uncommit is disabled?

Mike


More information about the zgc-dev mailing list