user84592
user84592

Reputation: 4882

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

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?

Upvotes: 12

Views: 11631

Answers (2)

Cory Klein
Cory Klein

Reputation: 55670

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

Upvotes: 13

keiki
keiki

Reputation: 3459

Can be done. See IBMs blog.

Basically you open both and then in the histogram there is an additional button (the most right one) to compare it.

Upvotes: 2

Related Questions