I have below settings for ZGC, when using extended memory, memory is not given back, it looks like SoftMaxHeapSize is ignored totally, only when I do a forced GC cycle memory is given back. What might be the reason and is it worth a bug report?
JDK: graalvm-jdk-21.0.1
-Xmx24G
-XX:+UnlockExperimentalVMOptions
-XX:+UseZGC
-XX:+ZGenerational
-XX:+UseNUMA
-XX:SoftMaxHeapSize=4G
-XX:ZUncommitDelay=16
I created a gist for the GC log, at [191.338s] there is a full GC forced: https://gist.github.com/thhart/d4acb994de1866eeedcce428e583b89a
SoftMaxHeapSize is a 'soft' limit to the heap size. It doesn't prevents the heap to grow beyond that limit when needed. It is a best effort limit. It should be expected that the heap may grow over it. Then it is up to the GC on when to reclaim memory over that limit.
According to Oracle garbage collection documentation:
This blog post provides more details and examples of how it behaves and suggestions on how to reclaim memory. Note that playing with these configurations can cause performance issues. Thorough performance testing is always recommended when changing GC configurations.