Jmap
The JDK comes with some tools to help us see the heap memory running by the JVM, often with the jmap command
Jmap-heap <pid> Print Heap usage
Well, from this output we can also roughly see the structure of the heap, divided into young Generation (younger generation) and old Generation (older)
Young generation is also classified as: Eden space, from space and to space
You can see that the to area is clean and not yet in use, and the from zone has been used for 95%.
Jmap-histo[:live] <pid> Print the number of instances of the class, the memory used, the name of the class, usually we do not need to look at all, just look at the first few can
Jmap-dump:live,format=b,file=heap.bin <pid>
Use of dump heap in hprof binary format (PS: equivalent to generating a snapshot, we can analyze this snapshot file later)
Memory Analyzer (MAT)
After the file is dump, you can view it using Eclipse's Mat plugin
If you use Eclipse for daily development, you can install the plugin directly, and if not, the plugin can run independently.
www.eclipse.org/mat/
www.eclipse.org/mat/downloads.php
Double-click MemoryAnalyzer.exe to run after decompression
Open the Heap.bin file just now
You can see that there are three tabs below, including actions and reports that you can perform
Let's see the first one histogram .
Since this is a random project, there are no memory leaks and so on, so what we see here are some basic Java classes
View References
Dominator Tree can see the proportions of biggest object and the amount of memory they occupy
Our first-level search, you can find the source file, and then analyze the code, and ultimately locate the root cause of the problem
Jconsole
You can view a local process or a process on a remote host
Example: Jconsole 192.168.102.16:9105
or local
Other
Reference
78675960
Www.cnblogs.com/kongzhongqijing/articles/3621163.html
52460008
51874097