Java 已用、已提交和最大堆内存的差异
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41468670/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference in Used, Committed and Max Heap Memory
提问by Alok
I am monitoring a spark executor JVM of a OutOfMemoryException. I used Jconsole to connect to executor JVM. Following is the snapshot of Jconsole:
我正在监视 OutOfMemoryException 的 Spark 执行程序 JVM。我使用 Jconsole 连接到执行器 JVM。以下是 Jconsole 的快照:
In the image used memory is shown as 3.8G and committed memory is 8.6G and Max memory is also 8.6G Could anyone explain the difference between Used and Committed Memory or any link which explains it.
在图像中,已用内存显示为 3.8G,提交内存为 8.6G,最大内存也是 8.6G 谁能解释已用内存和已提交内存之间的区别或任何解释它的链接。
回答by musibs
From the Java Doc of MemoryUsage
,
来自 的 Java 文档MemoryUsage
,
getUsed is:
getUsed 是:
the amount of used memory in bytes
已用内存量(以字节为单位)
getCommitted()
得到提交()
Returns the amount of memory in bytes that is committed for the Java virtual machine to use. This amount of memory is guaranteed for the Java virtual machine to use.
返回提交给 Java 虚拟机使用的内存量(以字节为单位)。此内存量保证供 Java 虚拟机使用。
getMax()
获取最大值()
Returns the maximum amount of memory in bytes that can be used for memory management. This method returns -1 if the maximum memory size is undefined.
This amount of memory is not guaranteed to be available for memory management if it is greater than the amount of committed memory. The Java virtual machine may fail to allocate memory even if the amount of used memory does not exceed this maximum size.
返回可用于内存管理的最大内存量(以字节为单位)。如果未定义最大内存大小,则此方法返回 -1。
如果该内存量大于提交的内存量,则不能保证该内存量可用于内存管理。即使使用的内存量未超过此最大大小,Java 虚拟机也可能无法分配内存。