0

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.

trincot
  • 317,000
  • 35
  • 244
  • 286
Roger Zhang
  • 33
  • 1
  • 3
  • possible duplicated by http://stackoverflow.com/questions/561245/virtual-memory-usage-from-java-under-linux-too-much-memory-used – waltersu Jun 14 '16 at 07:42

1 Answers1

0
  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.

NewBee
  • 1,331
  • 12
  • 13