How to Analyze Memory Using Android Studio

How to analyze memory using android studio

I'll explain it in an easy way with steps:

  1. First, you have install MAT ( download ) or use:

    brew cask install memoryanalyzer

  2. In Android Studio open Android Device Monitor or DDMS.

  3. Select your process "com.example.etc.."

  4. Click Update Heap above the process list.

  5. In the right-side panel, select the Heap tab.

  6. Click in Cause GC.

  7. Click Dump HPROF file above the process list.

  8. When we downloaded the file HPROF, we have to open the Terminal and run this command to generate the file to open it with MAT.

  9. Open terminal and run this command

./hprof-conv path/file.hprof exitPath/heap-converted.hprof

The command "hprof-conv" is in the platform-tools folder of the sdk.


  1. And ready and MAT can open and open the converted file ( heap-converted.hprof ) .

Memory Analyzer Tool in android?

  1. Open DDMS perspective in Eclipse.
  2. Select Devices tab.
  3. Choose a process you want to make a dump for.
  4. Click Dump HPROF file button. The dump will be made and MAT window will be opened, assuming MAT is installed.
  5. Choose Leak Suspects Report in the wizard window and click Finish.

That's all. You'll se a list of possible leaks, but some of them are false-positive. I recommend you to run an activity you want to check leaks in several times and then run MAT again.

How can I find which objects take most of the memory in android 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

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.

Android Studio Profiler Memory Allocated N/A

I had the same issue and here's what I did to make it work. (This is effective when running on API level < 26 only)

  1. In Android Studio, go to the Configurations menu as shown in the image below and click on Edit Configurations.

Edit Configurations menu


  1. Select your app configuration from the menu on the left (usually called "app").
  2. Click on the Profiling tab.
  3. Check "Enable advanced profiling".

Configurations Enable Advanced Profiling



Related Topics



Leave a reply



Submit