The Maximum Java Heap Size (Xmx) is the maximum amount of memory that Java application can uses. A lower Xmx value will cause a decrease in performance due to JVM has to force frequent garbage collections in order to free up space, also if the Xmx value is lower than the amount of live data, it might trigger OutOfMemoryError. Customers can configure Xmx via JVM options
-Xmx to optimize their Java application performance, but quite a lot of Java users never explicitly specify the
-Xmx option, so in those cases the default Xmx has been used. The default values for Xmx is based on the physical memory of the machine.
In current OpenJ9 release 0.19:
For Java 11 and above
The Xmx value is 25% of the available memory with a maximum of 25 GB. However, where there is 2 GB or less of physical memory, the value set is 50% of available memory with a minimum value of 16 MB and a maximum value of 512 MB.
For Java 8
The Xmx value is half the available memory with a minimum of 16 MB and a maximum of 512 MB.
Changes to default Java Maximum Heap Size for Java 8
From OpenJ9 release 0.20, The default Java Maximum Heap Size (Xmx) is changed to be consistent with Java 11, so by default in Java 8, 25% physical memory up to 25GB for the Xmx will be expected. If you want to revert to the default setting in earlier releases of OpenJ9, use the
-XX:[+/-]OriginalJDK8HeapSizeCompatibilityMode is new option for release 0.20, but it is deprecated and should only be used in case you want to keep earlier releases behavior of default Xmx.
Keep in mind this change only affect the behavior of the default Xmx in Java 8 and there is no change for Java 11 and above. the option
-XX:[+/-]OriginalJDK8HeapSizeCompatibilityMode is also ignored in Java 11 and above.
Verify Maximum Heap Size
If you want to confirm maximum heap size for your OpenJ9 release in runtime, you can simply verify the default max heap size via
-verbose:gc options. you can find out the result in initialized section of verbosegc.
./java -verbose:gc -version
For OpenJ9 Java8 release 0.19 or earler, On 4GB physicalMemory machine the default Xmx is 512MB.
For OpenJ9 Java8 release 0.20, On 4GB physical memory machine the default Xmx is 1GB.