I am trying to figure out why Shenandoah GC is not returning memory to the OS. My understanding is that MinHeapFreeRatio and MaxHeapFreeRatio when both set to a number N, would maintain the amount of free space of N% compared to total committed. In other words, the extra free memory beyond the limit is returned to the OS.
JVM has been started with the following options: -Xms32m -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=10 -XX:+UseShenandoahGC -XX:+UnlockExperimentalVMOptions -XX:ShenandoahUncommitDelay=1000 -XX:ShenandoahGuaranteedGCInterval=10000
Based on this I would expect to see about 10% of free heap memory. However, when getting stats of the memory usage I get these values (a typical example for a long running process):
C:\zulu11.54.23-ca-jdk11.0.14-win_x64\bin>jhsdb jmap --heap --pid 9076
...
Heap Configuration:
MinHeapFreeRatio = 10
MaxHeapFreeRatio = 10
MaxHeapSize = 4831838208 (4608.0MB)
NewSize = 1363144 (1.2999954223632812MB)
MaxNewSize = 17592186044415 MB
OldSize = 5452592 (5.1999969482421875MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
ShenandoahRegionSize = 2097152 (2.0MB)
Heap Usage:
Shenandoah Heap:
regions = 2304
capacity = 4831838208 (4608.0MB)
used = 81630792 (77.84918975830078MB)
committed = 507510784 (484.0MB)
Comparing used and committed, it appears that the amount of free memory is actually 84%! Any suggestions as to why this may be?