ZGC | Using -XX:SoftMaxHeapSize
In JDK 13 we introduced a new JVM option called -XX:SoftMaxHeapSize=<size>. ZGC is so far the only garbage collector in HotSpot that supports this options, but work to also support it in G1 is ongoing. Since this option is relatively new, and perhaps not yet widely known, I thought I’d write a few words about when and how to use it. When is -XX:SoftMaxHeapSize useful? As the name implies, this new option sets a soft limit on how large the Java heap can grow. When set, the GC will strive to not grow the heap beyond the soft max heap size. But, the GC is still allowed to grow the heap beyond the specified size if it really needs to, like when the only other alternatives left is to stall an allocation or throw an OutOfMemoryError. There are different use cases where setting a soft max heap size can be useful. For example: When you want to keep the heap footprint down, while maintaining the capability to handle a temporary increase in heap space requirement. Or when you want...