java中提交内存的确切状态
我很好奇当从 MemoryUsage 类查询该值时,“提交”内存的确切含义是什么。 该类将其解释为“已提交代表保证可供 Java 虚拟机使用的内存量(以字节为单位)”。 这是否意味着该内存正在被 jvm 进程使用,并且在被 java 进程释放之前不可用于其他进程,或者是否意味着如果 java 进程尝试分配最多该内存量,它就会成功? 我意识到这可能是特定于实现的,但我只对热点感兴趣。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
提交的大小是实际分配的内存,使用的大小是用于存储实际数据的大小(当使用〜=提交时,是主要GC的时间,并且可能会增加堆)。 最大大小是堆可以增长的硬限制 - 如果不够,JVM 会抛出 OutOfMemoryError。
如果内存被提交,那么它肯定可以被使用。 此外,JVM 无法提交更多内存(在现代操作系统上)的唯一情况是硬件虚拟内存不足。
所有这些大小仅告诉您堆区域的大小。 JVM 还有其他内存区域(线程堆栈、JIT 缓存等)。堆区域通常是最大的,这大致对应于进程占用空间。
两个注意事项:
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.
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.
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.
Two notes:
“这是否意味着内存正在被 jvm 进程使用,并且不可用于其他进程”是正确的。 因此它小于(或等于)操作系统认为 JVM 进程占用的内存量。
http://java.sun.com/j2se/ 1.5.0/docs/guide/management/jconsole.html(抱歉没有可链接的锚点)。
"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.
http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html (sorry no anchors to link to).