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.
-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 188.8.131.52 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:
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
-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
-Xmxparameter 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
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
-Xmsto the value of
-Xmxto 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
-XX:InitialRAMPercentage=<value>This is an alternative to
-Xmsand 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
-Xmxand 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.