xmlx 和 MaxRAM JVM 参数有什么区别?
MaxRAM:
基于机器上的内存量.用于堆的内存比例由命令行选项 InitialRAMFraction 和 MaxRAMFraction 控制[...]MaxRAM 的值取决于平台.
based on the amount of memory on the machine. The proportion of memory to use for the heap is controlled by the command-line options InitialRAMFraction and MaxRAMFraction [...] The value of MaxRAM is platform-dependent.
Xmx:
-Xmxn指定内存分配池的最大大小(以字节为单位).此值必须是大于 2MB 的 1024 的倍数.附加字母 k 或 K 表示千字节,或附加 m 或 M 表示兆字节.默认值为 64MB.此值的上限在 Solaris 7 和 Solaris 8 SPARC 平台上约为 4000m,在 Solaris 2.6 和 x86 平台上约为 2000m,减去开销.
-Xmxn Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. The upper limit for this value will be approximately 4000m on Solaris 7 and Solaris 8 SPARC platforms and 2000m on Solaris 2.6 and x86 platforms, minus overhead amounts.
据我了解,两者都定义了 heap
大小.不?推荐使用什么:Xmx
或 MaxRAM
?如果我同时使用哪一个 ovverides 另一个?
As I understand both define heap
size. No? What is recommended to use: Xmx
or MaxRAM
? If I use both which one ovverides another?
推荐答案
-Xmx
指定堆的精确上限.这是设置堆大小的首选方式.
-Xmx
specifies the precise upper limit for the heap. It is the preferred way to set the heap size.
-XX:MaxRAM
不直接定义堆大小.相反,在根据人体工程学计算堆限制时,此参数会覆盖物理 RAM 的实际数量.
-XX:MaxRAM
does not define the heap size directly. Instead this parameter overrides the actual amount of physical RAM when calculating the heap limits basing on ergonomics.
如果设置了 -Xmx
,则永远不会使用 MaxRAM
.否则最大堆大小估计1为
If -Xmx
is set, MaxRAM
is never used. Otherwise the maximum heap size is estimated1 as
MaxHeapSize = MaxRAM * MaxRAMPercentage / 100% (default MaxRAMPercentage=25)
<小时>
1 实际的算法稍微复杂一些,还要依赖其他参数.
1 The actual algorithm is a bit more complicated and depends on other parameters.
相关文章