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 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.
据我了解,两者都定义了堆
大小。不?建议使用什么:Xmx
或 MaxRAM
?如果我同时使用哪一个会优先于另一个?
最佳答案
-Xmx
指定堆的精确上限。这是设置堆大小的首选方法。
-XX:MaxRAM
不直接定义堆大小。相反,在根据人体工程学计算堆限制时,此参数会覆盖物理 RAM 的实际数量。
如果设置了-Xmx
,则永远不会使用MaxRAM
。否则,最大堆大小估计为1为
MaxHeapSize = MaxRAM * MaxRAMPercentage / 100% (default MaxRAMPercentage=25)
<小时/>
1 实际 algorithm有点复杂,取决于其他参数。
关于java - xmx 和 MaxRAM JVM 参数有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57920155/