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.
-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 Zulu Prime Builds of OpenJDK (Azul Zulu Prime JVM) 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 Zulu Prime 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
-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 GC Log Analyzer). By default, the garbage collector tries 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%.
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:
-Xmx10GThe 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 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
-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 ZST is installed, and the minimum heap size then is always equal to
-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.
-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. 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.