If you add -XX:+HeapDumpOnOutOfMemoryError on the JVM argument, when OOM occurs it’ll leave a heap dump.
How to use MAT to analyze heap dump file
- After opening up the .hprof file, you’ll see below overview
Dominator Treewill show what’s consuming most of the heap spaces

- Shallow Heap: The size of the object itself
- Retained Heap: The size of the other objects that it is referring
Leak Suspectswill show suspicious thread and the stacktracesHistogramwill show list of objects by class. Using histogram, we can get a clue of suspects





Leave a comment