Contingency Memory
The -Xmx
command line option on the Java application command line specifies the amount of Java heap memory to be reserved by the Azul Zing Builds of OpenJDK (Zing) running a Java application. Zing instances can require additional Java heap memory for assorted reasons, including unplanned events and incremental memory needs.
To help ensure that Zing instances survive unanticipated peak loads and to prevent out of memory errors, the system-config-zing-memory
tool sets aside a percentage of the System Zing memory for Contingency memory. Contingency memory is additional memory available to any Zing instance running a Java application.
The Zing instance uses Contingency memory to manage memory requests for space in the Zing instance’s Java heap.
Memory from Contingency memory is used as needed by Zing, growing and shrinking as the needs of Zing instances fluctuate:
-
Using Contingency memory allows Zing instances to be launched without extensive, up-front JVM or garbage collector tuning.
-
Zing instances are allowed to grow or shrink based on actual needs.
-
If sufficient Contingency memory is available, Zing instances are allocated extra memory, allowing them to continue processing without triggering an out of memory failure.
-
Applications can run with larger heap sizes to improve application performance. The heap size is no longer limited in an attempt to prevent potential garbage collection pauses.
Contingency Memory and Generational Pauseless Garbage Collection
Zing’s ability to temporarily increase the Java heap memory available to a process beyond the originally specified -Xmx
value is unique to the Zing Java platform. The only limits of Contingency memory use are:
-
How much unused memory remains in the Contingency memory
When a Zing instance running a Java application uses memory from the Contingency memory, the Zing instance automatically increases the frequency of garbage collections to ensure Java Heap memory is available for object allocation. If a Zing instance constantly uses Contingency memory, adjust the heap size when you restart the Zing instance. This adjustment can prevent spending excessive time in garbage collection. -
Limiting the Zing instance’s maximum Java Heap size
Use the-XX:JavaMemMax
command line option to specify the Java heap memory upper limit.
To prevent use of Contingency memory for a Zing instance, set the-XX:JavaMemMax
value equal to the-Xmx
value.
Sharing Contingency Memory and Memory Leaks
Contingency memory is reserve memory of memory for use in temporary high load situations. Do not depend on Contingency memory when calculating the -Xmx value for Zing instances running Java applications.
Contingency memory is shared among all Java processes on the system. It can only be effective in preventing processes from terminating with an out of memory error if the increases in memory requested by each of the Zing instances are kept to a minimum.
Once a Zing instance is using memory from Contingency memory, the application is at some risk because there are no guarantees that additional Contingency memory will be available when needed because Contingency memory is a shared resource.