澄清新的JVM内存参数的含义InitialRAMPercentage和MinRAMPercentage [英] Clarification of meaning new JVM memory parameters InitialRAMPercentage and MinRAMPercentage
问题描述
参考: https://bugs.java.com/bugdatabase/view_bug.吗?bug_id = 8186315
我真的很难找出MinRAMPercentage的功能,尤其是与InitialRAMPercentage相比.
I'm really struggling to find out what MinRAMPercentage does, especially compared to InitialRAMPercentage.
我假设InitialRAMPercentage设置了启动时的堆数量,MinRAMPercentage和MaxRAMPercentage设置了允许JVM收缩/增长到的堆的上下限.
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.
显然不是这样.当我启动JVM(使用UseContainerSupport,具有这些新的内存设置参数)时,如下所示:
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和MaxHeap,我找不到最小堆大小"值;因此,该MinRAMPercentage似乎永远不会被使用.
InitialHeap and MaxHeap get set, there is no "Minimum Heap Size" value that I can find; Consequently, that MinRAMPercentage never seems to get used.
超级困惑,显然,我不是唯一的一个.我收集了此处 a>和此处.他们似乎选择不实施MinRAMPercentage afaics.
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.
所以:设置MinRAMPercentage的实际用途和效果是什么?
So: What is the real intended usage and effect of setting MinRAMPercentage?
推荐答案
-XX:InitialRAMPercentage
is used to calculate initial heap size when InitialHeapSize
/ -Xms
is not set.
这听起来违反直觉,但是当未设置MaxHeapSize
/-Xmx
时,-XX:MaxRAMPercentage
和-XX:MinRAMPercentage
都用于计算最大堆大小:
It sounds counterintuitive, but both -XX:MaxRAMPercentage
and -XX:MinRAMPercentage
are used to calculate maximum heap size when MaxHeapSize
/ -Xmx
is not set:
-
对于物理内存较小的系统,
MaxHeapSize
估计为
phys_mem * MinRAMPercentage / 100 (if this value is less than 96M)
否则(非小物理内存)MaxHeapSize
估计为
MAX(phys_mem * MaxRAMPercentage / 100, 96M)
确切的公式要复杂一些,因为它还要考虑其他因素.
The exact formula is a bit more complicated as it also takes other factors into account.
注意:用于计算初始堆大小和最大堆大小的算法取决于特定的JVM版本.控制堆大小的首选方法是显式设置Xmx
和Xms
.
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.
另请参见此问题.
这篇关于澄清新的JVM内存参数的含义InitialRAMPercentage和MinRAMPercentage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!