-XX:InitialRAMPercentage is used to calculate initial heap size when InitialHeapSize / -Xms is not set.
It sounds counterintuitive, but both -XX:MaxRAMPercentage and -XX:MinRAMPercentage are used to calculate maximum heap size when MaxHeapSize / -Xmx is not set:
For systems with small physical memory
MaxHeapSizeis estimated asphys_mem * MinRAMPercentage / 100 (if this value is less than 96M)Otherwise (non-small physical memory)
MaxHeapSizeis estimated asMAX(phys_mem * MaxRAMPercentage / 100, 96M)
The exact formula is a bit more complicated as it also takes other factors into account.
Note: the algorithm for calculating initial and maximum heap size depends on the particular JVM version. The preferred way to control the heap size is to set Xmx and Xms explicitly.
See also this question.
Answer from apangin on Stack Overflow[Bug]: JVM InitialRAMPercentage/MaxRAMPercentage options ignored
Out of Memory Error in openjdk Container
java - Why should we set -XX:InitialRAMPercentage and -XX:MaxRAMPercentage to the same value for cloud environment? - Stack Overflow
Heap size allocation in SUSE using MinRAMPercentage instead of MaxRAMPercentage values although heap size > 250 MB - SUSE Linux Enterprise Desktop - SUSE
-XX:InitialRAMPercentage is used to calculate initial heap size when InitialHeapSize / -Xms is not set.
It sounds counterintuitive, but both -XX:MaxRAMPercentage and -XX:MinRAMPercentage are used to calculate maximum heap size when MaxHeapSize / -Xmx is not set:
For systems with small physical memory
MaxHeapSizeis estimated asphys_mem * MinRAMPercentage / 100 (if this value is less than 96M)Otherwise (non-small physical memory)
MaxHeapSizeis estimated asMAX(phys_mem * MaxRAMPercentage / 100, 96M)
The exact formula is a bit more complicated as it also takes other factors into account.
Note: the algorithm for calculating initial and maximum heap size depends on the particular JVM version. The preferred way to control the heap size is to set Xmx and Xms explicitly.
See also this question.
Depends on your container memory also, So lets suppose you have container memory as 1 GB then in this case -XX:MaxRAMPercentage=80 will be used to determine the max heap ~ 800mb heap memory will be used
And suppose you have container memory less than 250mb then -XX:MinRAMPercentage=20.0 will be used ~ 50mb heap memory will be used
use this article to understand more XX:MinRAMPercentage,XX:MaxRAMPercentage
Hi all,
I'm running a JVM application in a containerized environment and I want to maintain a constant heap size. I'd also really like to define that size as a percentage, rather than an absolute number. For example, if the container gets 4G memory, I'd like to be able to specify 75% for the JVM heap, rather than 3G for the JVM heap.
I know that I can do this by setting -Xms and -Xmx to the same absolute value. For example, with -Xms3G -Xmx3G, the memory profile in VisualVM looks like this:
Now I'm struggling to do the same thing with -XX:InitialRamPercentage, -XX:MinRamPercentage, and -XX:MaxRamPercentage. For example, if I set them all to 75 in a 4G container, I get a memory profile where the heap size is actually rapidly changing over time:
I've read through the docs for these params and some tutorials, and it doesn't sound like there's a way to do this with the percentages. Hopefully I'm overlooking something though. Thanks in advance :)