Visit Azul.com Support

Recommended Heap Size

Looking for Zing? The Azul Zing Virtual Machine is now Azul Zulu Prime Builds of OpenJDK and part of Azul Platform Prime. Learn more.

Use the -Xmx command line to specify the Java heap size. The Azul Zulu Prime Builds of OpenJDK (Azul Zulu Prime JVM) instance uses the specified Java heap size to calculate the size of Reserved memory.

Starting with Azul Platform Prime 19.8.0.0 the minimum heap size for Azul Zulu Prime JVM is 512 MB.

In Azul Platform Prime 21.05.0.0, Azul Zulu Prime JVM introduce a new feature called Heap Elasticity. This feature is not available when the Azul Zulu Prime System Tools are installed, and is disabled by default. To enable it, use the following command line option:

-XX:+GPGCNoZSTHeapElasticity

Heap Elasticity provides elastic expansion and shrinking of the Java heap. When heap elasticity is enabled, 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.

Azul Zulu Prime JVM starts a background thread to monitor the garbage collection pressure and to acquire or release memory accordingly. The metric used to determine the pressure is the percentage of application execution time for which garbage collector runs concurrently (GC Time %, visible in GCLogAnalyzer). By default, the elasticity heuristics try to keep this metric within a range of 5% to 20%. More memory is acquired for the Java heap if the metric is predicted to exceed 20% and memory is released if the metric is predicted to drop below 5%.

Related flags when heap elasticity is enabled:

  • -Xmx<size>[m|M|g|G] Specifies the maximum size of the Java heap. Examples to specify a 10GB heap: -Xmx10240M or -Xmx10G The minimum value is 512 MB. Starting with Azul Zulu Prime 21.05.0.0, the default value when no -Xmx parameter is set matches OpenJDK and is 25% of the system RAM or cgroup limit (container limit). The upper limit of the default value is 32GB. The possible maximum setting is 2500GB (2.5TB). When Azul Zulu Prime System Tools are installed, the default value is 1GB and the maximum is 20000GB (20TB).

  • -Xms<size>[m|M|g|G] This flag was ignored in Azul Zulu Prime versions before 21.05.0.0 and internally always set to the -Xmx value.

    Since 21.05.0.0, this flag specifies the minimum size of the Java heap that is committed at the start of the Java command. 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 depending on the system RAM and ranges from 512 MB to 2 GB. This parameter is ignored when Zulu Prime System Tools are installed and the minimum heap size then is always equal to -Xmx.

  • -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. This parameter is only used when heap elasticity is enabled. The default value is 15.

  • -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. The default value is 25.0, but the default is capped to a maximum of 32 GB.