What's in the heap dump file.
How many objects each class has, and what their values are, can be found in the heap dump file. 1.heap Dump
In addition to using the visual VM, you can use the Jmap command. Especially if the remote machine doesn't give you an open port connection, you can only use the original command-line tool.
Will pid=9406 the heap of this Java process, dump it into the heapdump.hprof file. Live means only output information for surviving objects
jmap-dump:live,format=b,file=heapdump.hprof 9406
This binary format file cannot be read directly. Suffix hprof can be understood as heap profile.
2.visual vm Simple Analysis
Figure 2-1 Visual VM's Heapdump file analysis view
3.Memory Analyzer
A plug-in for Eclipse. You can install it by searching in eclipse marketplace. Free, the function is stronger than VISUALVM.
Figure 3-1 Searching for and installing memory Analyzer
After installation, you can open a. hprof file to try.
Figure 3-2 Memory Analyzer View 4.OQL Object Lookup Language
Oql,object query Language, object lookup language.
There are thousands of classes in the heap dump file, such as popular classes like java.lang.String, and there may be thousands of objects. How to quickly find the object you are interested in, it is necessary to use the OQL.
The OQL in VISUALVM is inconsistent with the OQL syntax in Memory Analyzer, which requires attention. 4.1 Memory Analyzer's Syntax
Searches for objects with a value of "mozilla.*" in the String class. Note that the wildcard character is ' * ', not in SQL '% '
select * from java.lang.String s where toString (s) is like "mozilla.*"
5.shallow size and retained sizeShallow size is the sum of the size of the object's own base type data. Java references are equivalent to C + + pointers, so it occupies 8 bytes on a 64-bit platform and occupies 4 bytes on 32-bit platforms.
Retained size is the object's own shallow size plus the sum of the shallow size from which the object can be accessed directly or indirectly.