Search code examples
javagarbage-collectionjava-11zgc

Make ZGC run often


ZGC runs not often enough. GC logs show that it runs once every 2-3 minutes for my application and because of this, my memory usage goes high between GC cycles (as high as 90%). After GC, it drops to as low as 20%.

How to increase GC run's frequency to run more often?


Solution

  • -XX:ZCollectionInterval=N - set maximum gap between collections to N seconds.
    -XX:ZUncommitDelay=M - set the delay until unused memory is returned to the OS to M seconds.