9

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?

1 Answer 1

5
+25

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.