简体   繁体   中英

java heap memory is larger than TOP

My program run with -Xms10240m -Xmx10240m. I use top to check the memory, the size is 3.5g, it is smaller than the xms valuse. use top

However, when I use jmap -heap, I can see the heap size is about 10g. use jmap

What's the reason?

Thanks.

  1. -Xms option is used for JVM min-heap size definition
  2. top shows the real memory(VIRT/RES/SHR) process used

use your example -Xms10g -Xmx10g , when jvm start, it will ask op-system allocation 10g memory which will be used for heap. And op-system will try to allocate the memory for the JVM (show as VIRT), but system did not promise u it will allocate physical memory, it maybe swap ;)

But u will find the VIRT is still not 10g, that reason is 10g is for heap size, a JVM include much more the heap, for example, stack, permgen(hotspot JDK8, openJDK seems has no permgen, fix me if i am wrong), native stack, code, files etc.

And RES is for real physical memory used , it includes new objects, method etc, still not only the heap too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM