Visit Azul.com Support

Java Heap Memory

Table of Contents
Need help?
Schedule a consultation with an Azul performance expert.
Contact Us

Java heap memory is the amount of memory dynamically allocated to an Azul Zing Builds of OpenJDK (Zing) instance running on the system. Objects in Java heap can be shared between threads.

Its size is specified using the –Xmx command-line option. It is the amount of memory the Zing instance needs to run the Java application, not including Pause Prevention and Contingency memory.

The -XX:JavaMemMax option allows you to set an upper bound on the amount of memory used for the Java heap. If this option is not set, the maximum is unlimited, though, in practice, it is limited by the size of the Contingency Memory.

  • A larger Java heap

    • Allows more objects to be created

    • Takes longer to fill

    • Allows the Zing instance to run longer between garbage collections (GC)

    • Consumes less CPU for garbage collection

  • A smaller Java heap

    • Holds fewer objects

    • Fills more quickly

    • Garbage is collected more frequently

    • May lead to out-of-memory errors

    • Consumes more CPU for garbage collection over time

Temporary Java Heap Memory

When needed to support the Java application, Zing temporarily allocates memory from Contingency memory and/or Pause Prevention memory. See Contingency Memory and Pause Prevention Memory.

Heap Memory in 32-Bit vs. 64-Bit Systems

Zing requires 64-bit systems. So, when determining the amount of Java heap memory to allocate, remember there is a difference in memory use in a 32-bit or 64-bit system.

Java heap memory requirements for 64-bit systems are generally 1.5 times greater than 32-bit systems. Though primitives such as integers use 32-bit words on either a 32-bit or 64-bit system, Java object headers and pointers use 32-bits on a 32-bit system and 64-bits on a 64-bit system. The result is that proportionally more memory is used to accommodate the same number of objects on a 64-bit system. This applies to all Java environments, whether they are running JVMs from other vendors or a Zing instance.

Additionally, the increased efficiency of the garbage collector on a 64-bit system, also requires additional space relative to a 32-bit system.

So, when migrating a system from a 32-bit to 64-bit environment, the amount of memory has to be increased to achieve the same performance. An increase of 1.5 times can be used as a guideline, but should be evaluated versus your SLAs.