java - xmx 和 MaxRAM JVM 参数有什么区别?

标签 java jvm heap-memory

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.

据我了解,两者都定义了大小。不?建议使用什么:XmxMaxRAM?如果我同时使用哪一个会优先于另一个?

最佳答案

-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/

相关文章:

java - 在 Android 中单击 Firebase 通知时将数据发送到 Activity

java - getClassloader 返回 null 而不是引导类加载器

java - 在运行时获取成员字段的源顺序的保证方法?

java - 在带有 ARM11 的设备中安装 JVM

java - 字符串 a == 字符串 b 的规则

java - 有没有一个软件可以实时查看JVM堆内存中对象的变化?

java - 栈、堆和递归

java - 在java中,在这个程序中,它突然在某个代码点停止正常运行?但它编译?有什么想法可能是什么问题吗?

java - Selenium - 通过 ul li 值文本从列表中选择项目

java - 在运行时更改 persistenceUnit 属性