Im curious what the exact meaning of "committed" memory is when the value is queried from the MemoryUsage class. That class explains it as "committed represents the amount of memory (in bytes) that is guaranteed to be available for use by the Java virtual machine." Does this mean that the memory is in use by the jvm process and NOT available to other processes until it is released by the java process, or does it mean that the java process will be successful if it tries to allocate up to that amount of memory? I realize this might be implementation specific but i am only interested in hotspot.
我很好奇当从MemoryUsage类查询该值时,“已提交”内存的确切含义。该类将其解释为“已提交表示保证可供Java虚拟机使用的内存量(以字节为单位)。”这是否意味着内存正在被jvm进程使用,并且在java进程释放之前不可用于其他进程,或者它是否意味着如果java进程尝试分配高达该内存量,则该进程将成功?我意识到这可能是特定于实现的,但我只对hotspot感兴趣。
2 个解决方案
#1
21
The committed size is the actually allocated memory, the used size is the size used for storing actual data (when used ~= committed it's time for major GC and possibly growing the heap). The Max size is the hard limit to which the heap can grow - if it's not enough the JVM throws OutOfMemoryError.
提交的大小是实际分配的内存,使用的大小是用于存储实际数据的大小(使用时〜=已提交主要GC的时间并可能增加堆)。最大大小是堆可以增长的硬限制 - 如果它不够,则JVM会抛出OutOfMemoryError。
If a memory is committed then it definitely can be used. Also, the only occasion when JVM would not be able to commit more memory (on a modern OS) is if the hardware is out of virtual memory.
如果提交了内存,那么肯定可以使用它。此外,JVM无法提交更多内存(在现代操作系统上)的唯一情况是硬件是否超出虚拟内存。
All these sizes only tell you the size of the heap region. The JVM has other memory regions as well (thread stacks, JIT cache, etc.) The heap region is usually largest, this roughly corresponds to the process footprint.
所有这些大小只告诉您堆区域的大小。 JVM还有其他内存区域(线程堆栈,JIT缓存等)。堆区域通常最大,这大致对应于进程占用空间。
Two notes:
- if the committed size does not fit in the physical memory, parts of it will be swapped to the page file. This leads to big slowdown during GC and in such cases you will improve the app performance by reducing the heap size.
- some operating systems allow double booking of memory - you can allocate as much as you want as long as you don't try to use it (forgot which OS it was - somebody fill me in)
如果提交的大小不适合物理内存,则部分内容将被交换到页面文件。这会导致GC期间大幅减速,在这种情况下,您将通过减小堆大小来提高应用程序性能。
一些操作系统允许双重预订内存 - 你可以根据自己的需要进行分配,只要你不尝试使用它(忘了它是哪个操作系统 - 有人填写我的内容)
#2
2
"Does this mean that the memory is in use by the jvm process and NOT available to other processes" would be the correct one. So its less then (or equal to) the amount of memory the OS sees as taken by the JVM process.
“这是否意味着jvm进程正在使用内存而其他进程无法使用”将是正确的。因此它少于(或等于)操作系统看到的JVM进程所占用的内存量。
http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html (sorry no anchors to link to).
http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html(抱歉没有要链接的锚点)。
#1
21
The committed size is the actually allocated memory, the used size is the size used for storing actual data (when used ~= committed it's time for major GC and possibly growing the heap). The Max size is the hard limit to which the heap can grow - if it's not enough the JVM throws OutOfMemoryError.
提交的大小是实际分配的内存,使用的大小是用于存储实际数据的大小(使用时〜=已提交主要GC的时间并可能增加堆)。最大大小是堆可以增长的硬限制 - 如果它不够,则JVM会抛出OutOfMemoryError。
If a memory is committed then it definitely can be used. Also, the only occasion when JVM would not be able to commit more memory (on a modern OS) is if the hardware is out of virtual memory.
如果提交了内存,那么肯定可以使用它。此外,JVM无法提交更多内存(在现代操作系统上)的唯一情况是硬件是否超出虚拟内存。
All these sizes only tell you the size of the heap region. The JVM has other memory regions as well (thread stacks, JIT cache, etc.) The heap region is usually largest, this roughly corresponds to the process footprint.
所有这些大小只告诉您堆区域的大小。 JVM还有其他内存区域(线程堆栈,JIT缓存等)。堆区域通常最大,这大致对应于进程占用空间。
Two notes:
- if the committed size does not fit in the physical memory, parts of it will be swapped to the page file. This leads to big slowdown during GC and in such cases you will improve the app performance by reducing the heap size.
- some operating systems allow double booking of memory - you can allocate as much as you want as long as you don't try to use it (forgot which OS it was - somebody fill me in)
如果提交的大小不适合物理内存,则部分内容将被交换到页面文件。这会导致GC期间大幅减速,在这种情况下,您将通过减小堆大小来提高应用程序性能。
一些操作系统允许双重预订内存 - 你可以根据自己的需要进行分配,只要你不尝试使用它(忘了它是哪个操作系统 - 有人填写我的内容)
#2
2
"Does this mean that the memory is in use by the jvm process and NOT available to other processes" would be the correct one. So its less then (or equal to) the amount of memory the OS sees as taken by the JVM process.
“这是否意味着jvm进程正在使用内存而其他进程无法使用”将是正确的。因此它少于(或等于)操作系统看到的JVM进程所占用的内存量。
http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html (sorry no anchors to link to).
http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html(抱歉没有要链接的锚点)。