为什么JVM使用比我分配的更多的内存 [英] Why is the JVM using more memory than I am allocating

查看:84
本文介绍了为什么JVM使用比我分配的更多的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下命令启动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它的内部堆可以使用多少内存.

-Xmxjust 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆