简体   繁体   中英

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?

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

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

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 .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM