The -XXSoftMaxHeapSize flag has been added in hotspot JVM in Java 13 release. Currently, it only has an effect on memory usage when the Z garbage collector is enabled (
The size of this flag is set in the number of bytes. When it is set, the garbage collector will strive to not grow the heap beyond the specified size, unless the GC decides it’s necessary to do so to avoid
Its value can not be set greater than the maximum heap size (-Xmx).
Bt default, its value is equal to the maximum heap size.
2. Changing value at runtime
This flag is manageable. Flags marked as manageable are dynamically writeable through the JDK management interface (
com.sun.management.HotSpotDiagnosticMXBean API) and also through JConsole.
HotSpotDiagnosticMXBean can be directly accessed and controlled from jconsole. In “MBeans” tab, choose
From the right panel, we can invoke the set operations on HotSpotDiagnosticMXBean and thereby explicitly manage any manageable JVM flag.
Drop me your questions in comments.
Happy Learning !!