5

I have developed an app, I want to check the Memory leak happening in the app. I am trying with eclipse MAT, but unsuccessful,I am getting HROF file but eclipse MAT unable to read it. Can anybody help me out. Any other way to findout.

Rahul Baradia
  • 11,802
  • 17
  • 73
  • 121
  • And you've read this post: http://android-developers.blogspot.com/2011/03/memory-analysis-for-android.html so what is confusing? – Morrison Chang Sep 21 '12 at 04:36
  • I have gone through this. I have got the heap dump file too. when I tried to open it in eclipse memory analyzer i.e MAT shows file cannot be read. – Rahul Baradia Sep 21 '12 at 04:44

3 Answers3

4

The dump.hprof file from Android needs to be converted. Then you can open the converted-dump.hprof in MAT.

hprof-conv dump.hprof converted-dump.hprof
Morrison Chang
  • 11,691
  • 3
  • 41
  • 77
3

I found this video very useful. This talks about things like how to find memory leaks from logcat(garbage collector logs) and how to use memory analyzer(MAT).

sujith
  • 2,421
  • 2
  • 17
  • 26
1

@sujith The video is very good. To summarize,

  1. the video talked about a very difficult-to-find leaking by "non-static inner class". There is a detailed explanation about this in this page.
  2. He talked about some important concepts when using Memory Analyzer Tool such as shallow heap vs. retained heap, GC Root and dominator tree.
  3. He showed an example of using MAT to identify a leak. In MAT the most useful tool said by him are Histogram and Dominator Tree. When examining an object further, he used right-click menu "Path to GC Root" and then "Exclude Weak References".
General Grievance
  • 4,555
  • 31
  • 31
  • 45
gm2008
  • 4,245
  • 1
  • 36
  • 38