MemoryMXBean.getHeapMemoryUsage()
I have a jvm process that ran with -Xms512m -Xmx512m, and below show the MemoryMXBean.getHeapMemoryUsage() of this process:
init = 512M
used = 105M
comitted = 491M
max = 491M
- Why max is 491M(I expect it to be 512M)?
MemoryMXBean.getNonHeapMemoryUsage() MemoryMXBean.getNonHeapMemoryUsage() of this process:
init = 2M
used = 25M
comitted = 25M
max = 0M
- What does the non-heap(who uses it) means? What kind of memory will be count into this non-heap? I only know that the direct memory we used in java code wouldn't(Am I right?)
-Xms
What does -Xms(The initial heap size) mean? I used to think that the initial heap size is how much memory jvm will actually allocate from os when the jvm start, but it turns out to be wrong. top shows that RES of this jvm is nearly 150m, but the jvm was ran with -Xms512M.
Is the below formula correct(or almost correct-_-)? If not, what should be considered too?
total memory a jvm used = used of MemoryMXBean.getHeapMemoryUsage()
+ used of MemoryMXBean.getNonHeapMemoryUsage()
+ the direct memory we used in application level
Anything would be appreciated!