Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: Memory Analyzer Tool (MAT) usage: comparing two heapdump

Tags:

java

profiling

I am using Eclipse + MAT plugin. I could see one .hprof file heap history, I take two snapshot of my Java application. I wish when I compare two heap dump, I could figure which objects instance increase a lot so that I could identify the potential of memory leak.

Could netbean do that?

like image 663
user84592 Avatar asked Sep 18 '12 11:09

user84592


1 Answers

Instructions

  1. Open both heap dumps in MAT
  2. Open the histogram for the whichever heap dump demonstrates the anomalous behavior (usually the one with the higher memory or thread usage).

enter image description here

  1. Compare it to another heap dump

enter image description here

  1. Select the appropriate heap dump from the list

enter image description here

Interpreting results

enter image description here

Class Name: The class that is instantiated in the application, taking up memory

Objects: The count of how many instances of the class are present above or below the other heap dump.

Shallow Heap: The number of bytes the given class is taking up in memory above or below the other heap dump.

Tips

Since MAT sorts descending by default I recommend toggling the ordering of the Objects and Shallow Heap columns to see the top outliers for each in both directions.

Typically you should ignore the pure Java classes like Strings, Arrays, and Maps and focus on the classes that your app defines.

Reference

Comparing Objects Official Eclipse Help Doc

like image 189
Cory Klein Avatar answered Oct 20 '22 20:10

Cory Klein