Visit Azul.com Support

Contingency Memory

Table of Contents
Need help?
Schedule a consultation with an Azul performance expert.
Contact Us
Looking for Zing?
The Azul Zing Virtual Machine is now Azul Zulu Prime Builds of OpenJDK and part of Azul Platform Prime.
Learn more

The -Xmx command line option on the Java application command line specifies the amount of Java heap memory to be reserved by the Azul Zulu Prime Builds of OpenJDK (Azul Zulu Prime JVM) running a Java application. Azul Zulu Prime JVM instances can require additional Java heap memory for assorted reasons, including unplanned events and incremental memory needs.

To help ensure that Azul Zulu Prime JVM 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 Azul Zulu Prime JVM instance running a Java application.

The Azul Zulu Prime JVM instance uses Contingency memory to manage memory requests for space in the Azul Zulu Prime JVM instance’s Java heap.

Memory from Contingency memory is used as needed by the Azul Zulu Prime JVM, growing and shrinking as the needs of Azul Zulu Prime JVM instances fluctuate:

  • Using Contingency memory allows Azul Zulu Prime JVM instances to be launched without extensive, up-front JVM or garbage collector tuning.

  • Azul Zulu Prime JVM instances are allowed to grow or shrink based on actual needs.

  • If sufficient Contingency memory is available, Azul Zulu Prime JVM 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

The Azul Zulu Prime JVM’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 Azul Zulu Prime JVM instance running a Java application uses memory from the Contingency memory, the Azul Zulu Prime JVM instance automatically increases the frequency of garbage collections to ensure Java Heap memory is available for object allocation. If a Azul Zulu Prime JVM instance constantly uses Contingency memory, adjust the heap size when you restart the Azul Zulu Prime JVM instance. This adjustment can prevent spending excessive time in garbage collection.

  • Limiting the Azul Zulu Prime JVM 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 Azul Zulu Prime JVM 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 Azul Zulu Prime JVM 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 Azul Zulu Prime JVM instances are kept to a minimum.

Once a Azul Zulu Prime JVM 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.