Using jdk1.8.0_152
I am trying to track down what part of my java program is using the most memory (mainly in the heap)
Using top
I see that the whole process is using around 1.109G of residual memory
Using jcmd {PID} VM.native_memory
I see that the total reserved is 4704896 KB and the committed is around 1290820 KB. Committed is slightly more than residual memory but I've read that not all committed memory could have been paged to actual memory so I'm not so concerned about that difference
The main concern I have right now is the difference between the heap memory usage from VM.native_memory
and total heap usage when I use jcmd {PID} GC.class_histogram
I've also tried to compare the heap usage using jstat -gc {PID}
and got results similar to GC.class_histogram
According to GC.class_histogram
and jstat -gc
, heap usage is around 250MB but using VM.native_memory
heap usage(committed in the Java Heap
section) is around 1000000KB (so little less than 1GB) but the actual RSS memory seems to be closer to the total committed in VM.native_memory
My guess right now is VM.native_memory
Java Heap contains memory that has not been garbage collected but even when I run garbage collection, I see that the result of jstat -gc
decreasing dramatically while VM.native_memory
isn't affected at all (although I've heard the user manually invoking garbage collection won't always lead to a full garbage collection but it seems at least that jstat -gc
seems to match the result from GC.class_histogram
.
Another thing I've heard is residual memory from top
isn't always freed when the process using the memory frees it until that memory absolutely needs to be freed.
So to sum up
VM.native_memory
showing a different heap memory usage from jstat
and GC.class_histogram
?top
might not always reflect the actual usage) i guess your jvm heap has been set with a range size.
native memory tracker displays memory size from os view (which is close to top
command), while jstat
displays at an inner perspective from jvm.
it means that jvm will request mem from os (check from top
), but really use it or not depends on itself (check by jstat
or jmap
).
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.