为什么JVM消耗的内存少于指定的-Xms? [英] Why does the JVM consume less memory than -Xms specified?
问题描述
我的问题是标题,通过搜索我获得了一些知识:
My question is as the title, and I got some knowledge by searching:
-
linux具有共享内存 如何衡量应用程序还是流程?
linux has shared memory How to measure actual memory usage of an application or process?
JVM将保留以Xms设置的内存量 -Xms JVM指的是什么意思堆内存?
JVM will reserve the amount of memory setted in Xms What does the -Xms JVM mean in reference to heap memory?
但是仍然不知道为什么,有些可以提供帮助吗?
But still don't know why, some on can offer some help?
这是我在Ubuntu12.04(64位)上运行的测试| JDK 1.7.0_04.顶部显示如下:
Here is my test run on Ubuntu12.04(64bit) | JDK 1.7.0_04. and top shows below:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4067 brian 20 0 5316m **262m** 7496 S 0 3.3 0:00.30 java -**Xms4096m** -Xmx4096m Test
4066 brian 20 0 3182m **256m** 7496 S 0 3.3 0:00.30 java -**Xms2048m** -Xmx2048m Test
4065 brian 20 0 2114m **252m** 7492 S 0 3.2 0:00.30 java -**Xms1024m** -Xmx1024m Test
4064 brian 20 0 1314m **76m** 7584 S 0 1.0 0:00.20 java -**Xms256m** -Xmx256m Test
4063 brian 20 0 1180m **51m** 7608 S 0 0.7 0:00.21 java -**Xms128m** -Xmx128m Test
推荐答案
您正在查看驻留内存-即消耗的物理RAM.有关更多信息,请参见此处.
You're looking at the resident memory - that is, the physical RAM consumed. See here for more info.
虚拟内存是应用程序消耗的内存,包括换出(到磁盘)的内存.您会发现与虚拟内存和-Xms
设置的对应关系更紧密.
The virtual memory, however, is the memory consumed by your application, including the memory swapped out (to disk). You'll see there's a closer correspondance with the virtual memory and your -Xms
settings.
有关更多信息,请参见此ServerFault答案
See this ServerFault answer for more info.
这篇关于为什么JVM消耗的内存少于指定的-Xms?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!