Visit 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 the minimum heap size for Azul Zulu Prime JVM is 512 MB.

In Azul Platform Prime, 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:


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 15%. More memory is acquired for the Java heap if the metric is predicted to exceed 15% 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, 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 and internally always set to the -Xmx value.

    Since, 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.