androidmacosandroid-studiomathprof

How can I find which objects take most of the memory in android app?


I am trying to see which objects take most of the memory in my app.
Using Android's studio Android->Memory tab I can see how the memory increases but I can't see which objects occupy how much memory.
I used DDMS to get an hprof and also did a start alocation tracking and "Dump Java Heap" from the Memory tab.
I installed the standalone mat but when I try to open the hprofs I get for both:

Error opening heap dump 'Snapshot_2016.01.08_19.00.05.hprof'. Check the error log for further details.

What is the problem?
My version of Android Studio is 1.3.2


Solution

  • Using Android's studio Android->Memory tab I can see how the memory increases but I can't see which objects occupy how much memory

    You can generate a heap dump on Android Studio, from the toolbar in that Memory tab. That will open up tools, akin to MAT, for you to peruse what objects are in memory.

    Android Studio 1.5.1, Showing Heap Dump

    Error opening heap dump 'Snapshot_2016.01.08_19.00.05.hprof'. Check the error log for further details.

    The heap dump format that Android uses is slightly different than the one MAT uses. There is an hprof-conv tool in platform-tools/ of your Android SDK that can prepare a MAT-friendly edition of the .hprof file.

    The documentation has a bit of material on this.