What does ZGC SoftMaxHeapSize really do?

1.1k Views Asked by At

I understand the aim of SoftMaxHeapSize, but I can't find what it really does. Hopefully someone familiar with JDK internals can shed some light.

Specifically, when the soft limit is reached:

  • Does it simply change ZCollectionInterval and ZUncommitDelay? To what values?
  • Or does it do something else?
  • How much additional CPU overhead can I expect?

Finally, will an application work fine if I do something like -XX:SoftMaxHeapSize=1M -Xmx=1T?

1

There are 1 best solutions below

0
On

As of JDK 16, using more live heap than SoftMaxHeapSize puts the app in a perpetual GC loop. I wouldn't call this optimal, but because ZGC is concurrent it doesn't have a catastrophic effect on the application. In my test it ate 1 additional CPU core (but I assume this would depend on the number of GC threads).

Additionally, seems that all GC heuristics (which tune things like how often GC should run) first look at SoftMaxHeapSize.