Heap dumps are typically used to diagnose memory issues, such as memory leaks. That is not the only thing they are useful for though.
Reports
Most obviously, we can see what kinds of reports are offered right away. I’m using Eclipse Memory Analyzer Tool here. Yourkit is also a great tool for analyzing heap dumps. Leak Suspects obviously helps you find where leaks might be. The Top Components is another view into similar data, to help you test your hypothesis about where the memory might be.
Threads
Thread dumps are also included with a heap dump, so you can see what objects threads may be holding onto. This is useful when investigating thread concurrency issues, especially deadlock related issues.
In this shot we can see that WebLogic has marked this thread as STUCK, and that it is in the EclipseLink ConcurrencyManager.acquireReadLock method, with a “Busy Monitor”. On the left we can see the attributes of the WeakCacheKey we are looking at. We can dig deeper from here. For instance we should go into the “activeThread” to see what it is doing, since it is blocking this ExecuteThread 44 from doing work.
Of course, knowledge of the code is required for comprehending these heap dumps. That can be quite difficult when digging through library code.
Other Tools
As with all your tools, it is worth your time to explore the options the tools have to offer, and find out how to properly use them. Before investigating the EclipseLink issue in the examples here, I really didn’t know how to look at the threads in a heap dump. I had only used MAT to generate a leak suspects report, and that was about the extent of my use of the tool.
I had to switch over to Yourkit. This gave me the view into the threads that I ended up realizing I wanted. Yourkit presents this information in a much prettier and friendly way than MAT. But after finding that, I came back to MAT to explore more. It turns out that I like MAT’s interface better. It is not as user-friendly or as pretty, but it is much snappier. MAT also presents the information I need better with it’s panel layout, so I do not need so many clicks.
Let me know if a more in-depth exploration of these tools, and heap dumps in general, would be useful!