Reference: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8186315
I'm really struggling to find out what MinRAMPercentage does, especially compared to InitialRAMPercentage.
I assumed that InitialRAMPercentage sets the amount of heap at startup, that MinRAMPercentage and MaxRAMPercentage set the bottom and top limit of heap that the JVM is allowed to shrink/grow to.
Apparently that is not the case. When I start a JVM (with UseContainerSupport, having these new memory setting parameters) like so:
java -XX:+UseContainerSupport -XX:InitialRAMPercentage=40.0 -XX:MinRAMPercentage=20.0 -XX:MaxRAMPercentage=80.0 -XX:+PrintFlagsFinal -version | grep Heap
InitialHeap and MaxHeap get set, there is no "Minimum Heap Size" value that I can find; Consequently, that MinRAMPercentage never seems to get used.
Super confused, and apparently, I'm not the only one; the OpenJ9 dudes seem to also not fully parse the intent of these options, as I've gathered here and here. They seem to have opted to simply not implement MinRAMPercentage afaics.
So: What is the real intended usage and effect of setting MinRAMPercentage?
Now let's discuss the most frequently used JVM Parameters which are 3 namely as follows: Java Heap Size. Garbage Collector. Print GC.
The flag Xmx specifies the maximum memory allocation pool for a Java virtual machine (JVM), while Xms specifies the initial memory allocation pool. This means that your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory.
-XX:MaxRAMPercentage=N. Set maximum heap size as a percentage of total memory. Where N is a value between 0 and 100, which can be of type "double". For example, 12.3456. Created by potrace 1.16, written by Peter Selinger 2001-2019 Note: If you set a value for -Xms , the -XX:InitialRAMPercentage option is ignored.
The default values for Xmx is based on the physical memory of the machine. The Xmx value is 25% of the available memory with a maximum of 25 GB. However, where there is 2 GB or less of physical memory, the value set is 50% of available memory with a minimum value of 16 MB and a maximum value of 512 MB.
-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 MaxHeapSize
is estimated as
phys_mem * MinRAMPercentage / 100 (if this value is less than 96M)
Otherwise (non-small physical memory) MaxHeapSize
is estimated as
MAX(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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With