Alex
Alex

Reputation: 7521

Why Heap total in the Java memory dump analyzer does not correspond to memory settings and the total JVM usage?

We use Eclipse memory analyzer for Java (Tomcat Web application) dump. The total heap in the resulting piechart is shown as 86 Mb. At the same time the heap limit for that JVM is set at 1.5GB and we saw the total JVM usage going up to 2.8 GB.

Why the deviation is so big?

Upvotes: 2

Views: 2093

Answers (3)

kevinmrohr
kevinmrohr

Reputation: 831

Your heap memory is only a part of the memory used by the JVM. Additionally you have native memory and permgen.

You can limit the permgen memory via command line parameters. See What does PermGen actually stand for?. In my experience, the permgen limit was defaulted to something like 1G, which was way more than we ever needed. I think we overrode it to 128m.

Native memory is a lot trickier. This is memory allocated by native libraries used directly or transitively by your code.

In jrockit, you can get a print out of a memory summary via jrcmd print_memusage. Not sure how to do that in other JVMs.

Also: http://www.ibm.com/developerworks/linux/library/j-nativememory-linux/index.html

Upvotes: 2

Aleš
Aleš

Reputation: 9028

See this reference - MAT Does Not Show the Complete Heap :

Symptom: When monitoring the memory usage interactively, the used heap size is much bigger than what MAT reports.

During the index creation, the Memory Analyzer removes unreachable objects because the various garbage collector algorithms tend to leave some garbage behind (if the object is too small, moving and re-assigning addresses is to expensive). This should, however, be no more than 3 to 4 percent. If you want to know what objects are removed, enable debug output as explained here: MemoryAnalyzer/FAQ#Enable_Debug_Output

Also, there should be some more information in this Q/A: eclipse memory analyzer sees small part (363,2MB) of entire heap dump (8GB)

Try the Keep Unreachable Objects option in Preferences -> Memory Analyzer -> Keep Unreachable Objects.

Upvotes: 2

Jakub Kubrynski
Jakub Kubrynski

Reputation: 14149

Please invoke jmap -heap TOMCAT_PID and you will see current heap usage (eden, survivor spaces, old and perm)

Also please notice that real usage of memory for Java will be XMX + MaxPerm + XSS * threads number. I'll recommend you reading great post about memory consuming in Java: http://plumbr.eu/blog/why-does-my-java-process-consume-more-memory-than-xmx

Upvotes: 3

Related Questions