Visit Azul.com Support

Recommended Heap Size

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

The -Xmx or -XX:MaxRAMPercentage command line parameters specifies the maximum Java heap size. That’s the amount of memory available for the Java application running on Azul Zing Builds of OpenJDK (Zing) to store its objects and classes.

Starting with Azul Platform Prime 21.07.0.0, the heap elasticity feature is enabled by default when Azul Zing System Tools (ZST) are not installed.

Heap elasticity provides elastic expansion and shrinking of the Java heap. The garbage collector tries to minimize the memory footprint, keeping it between the user-defined range of -Xms and -Xmx. At the same time, Azul Platform Prime monitors the CPU usage of the garbage collector and relaxes the memory minimizing goal when the CPU usage increases too much.

The metrics used to determine when to acquire or release memory are the percentage of wall-clock time the garbage collector concurrently (GC Time % metric visible in the GC Log Analyzer) and the CPU utilization of the GC threads. By default, the GC tries to keep the GC time below 40%, and the CPU utilization below 5% of all available CPUs. Memory is released when the GC time drops below 3%.

Flags to define the Java heap size:

  • -Xmx<size>[m|M|g|G] Specifies the maximum size of the Java heap.

    • Examples to specify a 10GB heap: -Xmx10240M or -Xmx10G.

  • Minimum and maximum heap sizes are as follows:

    • Minimum heap size for Xmx: 512 MB

    • Maximum heap size without ZST (x86): 2800 GB (2.8 TB)

    • Maximum heap size without ZST (ARM64): 5600 GB (5.6 TB)

    • Maximum heap size with ZST (x86): 20000 GB (20 TB)

      Intel Ice Lake and newer x86 processors, when 5-level paging (LA57) is enabled at the OS level, can have a maximum heap size of 14000 GB (14 TB).

    When ZST is installed, the default value is 1GB and the maximum is 20000GB (20TB).

  • -Xms<size>[m|M|g|G] Starting with 21.07.0.0, this flag specifies the minimum size of the Java heap that is committed at the start of the Java process. During uptime, the garbage collector uses this minimum value as target heap utilization to minimize the memory footprint. For application environments with primary goal of reducing latency and highest throughput performance, you should set -Xms to the value of -Xmx to avoid CPU-intensive memory optimization.

    The default value is 1.5625% of the total system memory or cgroup/container limit, and ranges from a minimum 128 MB to a maximum 2 GB. When ZST is installed, this parameter is ignored and the minimum heap size is equal to -Xmx, except when heap elasticity is enabled.

  • -XX:MaxRAMPercentage=<value> This is an alternative to -Xmx and defines the maximum heap size as percentage of the RAM of the machine, container or cgroup. With JDK 8, a decimal number is required as value, like 75.0. On JDK 11 and later integer numbers are also accepted.

  • -XX:InitialRAMPercentage=<value> This is an alternative to -Xms and defines the initial heap size as percentage of the RAM of the machine, container or cgroup. With JDK 8, a decimal number is required as value, like 5.0. On JDK 11 and later integer numbers are also accepted. For application environments with primary goal of reducing latency and highest throughput performance, you should set InitialRAMPercentage to the value of MaxRAMPercentage to avoid CPU-intensive memory optimization.