Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory usage in JVM profiler vs. Mac OS X Activity Monitor

I've been profiling my java application and have been confused about the reported memory usage of my application (run via eclipse). It's always very different to the memory usage reported by the profiler, and doesn't really even match itself.

The JVM flags for the application are:

-Xmx1G 
-Xms1G 	
-XX:MaxMetaspaceSize=256M
-XX:CompressedClassSpaceSize=256M

This image shows that the reported memory of the process "java" is 1.67GB. When I double click on that process, the breakdown shows 1.15GB of "Real Memory Size" and the various other memory metrics.

Reported Mac OS X memory usage

Flight recorder shows that the application adheres to its 1GB heap size. I have carried out tests that show that it also adheres to its metaspace limits.

Flight Recorder memory usage

My question is two fold: 1) Any idea why reported memory usage is so different between the process (as reported by Mac OS X) and the profiler? 2) Any idea why there's a disparity between memory shown in Activity Monitor and the breakdown of the process memory?

like image 408
alistair Avatar asked May 29 '17 19:05

alistair


Video Answer


1 Answers

1) Real memory is everything together: heap + stack + MetaSpace (formerly PermGen) + CompressedClassSpaceSize + etc. You limit the heap to 1GiB as shown by Flight Recorder. The OS shows everything together, not just the heap, that is where this disparity originates. It is not OS/JVM specific (i.e., try it on *nix, Windows, you will see the same).

2) That is OS specific. For Mac OS see this very detailed answer

like image 182
D. Kovács Avatar answered Sep 17 '22 13:09

D. Kovács