为什么JVM使用比我分配的更多的内存 [英] Why is the JVM using more memory than I am allocating
问题描述
我正在使用以下命令启动Java进程:
I am starting the Java process with the following command:
java -Xmx32m -jar winstone-lite.jar --warfile = myWarFile.war
java -Xmx32m -jar winstone-lite.jar --warfile=myWarFile.war
它并没有分配我指定的内存量,而是仍然分配了144m.
Instead of using the amount of memory I specified, it is still allocating 144m.
当我说分配时,我的意思是,当我看顶部"过程时,我看到144m是正在使用的内存量.
When I say allocate, I mean when I look at the "top" process I am seeing 144m as the amount of memory being used.
我正在使用 http://www.oracle.com/technetwork /java/embedded/documentation/index.html 当前版本.
I am using http://www.oracle.com/technetwork/java/embedded/documentation/index.html current version.
我认为,如果我的应用程序需要的内存比我分配的jvm多,则会崩溃.
I would figure that if my application required more memory than I am allocating the jvm would crash.
推荐答案
-Xmx
只是告诉JVM它的内部堆可以使用多少内存.
-Xmx
just tells the JVM how much memory it may use for its internal heap.
JVM需要将内存用于其他目的(永久生成,临时空间等),并且像每个二进制文件一样,它也需要用于其自己的二进制代码的空间以及任何库/DLL/.so才能加载.
The JVM needs memory for other purposes (permanent generation, temporary space etc.), plus like every binary it needs space for its own binary code, plus any libraries/DLLs/.so it loads.
您引用的144 MiB可能至少包含其他一些内存使用.
The 144 MiB you quote probably contains at least some of these other memory uses.
您如何衡量内存使用情况?在使用虚拟内存的现代OS上,测量进程的内存使用情况并非易事,并且不能表示为单个值.
How did you measure the memory usage? On modern OS using virtual memory, measuring memory usage of a process is not quite trivial, and cannot be expressed as a single value.
这篇关于为什么JVM使用比我分配的更多的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!