I just want to know how to work with Memory analyzer tool in android. Please tell me how to do this to know about memory leaks for a particular project. Can someone give me step wise procedure for this.
7 Answers
- Open DDMS perspective in Eclipse.
- Select Devices tab.
- Choose a process you want to make a dump for.
- Click Dump HPROF file button. The dump will be made and MAT window will be opened, assuming MAT is installed.
- 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.

- 53,859
- 22
- 133
- 139
-
1Thank You,let me check it out......Actually i want to know memory leak for a particular project or activity how would i load a particular project for memory leak – Taruni May 21 '11 at 09:57
-
3.Choose a process you want to make a dump for...what is the process here...i didnt get – Taruni May 21 '11 at 10:02
-
I hope you don't have thousands of leaks so it will not be so difficult to find all leaks for a particular object. But I don't think MAT has such a feature to search leaks of some objects. It just searches all possible leaks. – Michael May 21 '11 at 20:38
-
1When you open the Devices tab in the DDMS perspective, you'll see a list of devices and for every device there will be a list of processes that are launched on this device. One of this processes will be your application's process. It has a name equal to a package name of your application. Select this process and follow the next step. – Michael May 21 '11 at 20:41
-
Hey thanks for ur reply...when i clicked the Dump hprof file i am getting the following error::: hprof: can't open /sdcard/profileit.ImageDemo.hprof-hptemp: Permission denied. – Taruni May 23 '11 at 03:59
-
Sounds strange. I've never faced such an error. Try googling it. – Michael May 23 '11 at 05:13
-
Try using another device or emulator. – Michael May 23 '11 at 07:35
-
Ya i tried with different emulators but still getting the same error...Is there any other way to find the memory leaks without using MAT...Any other tool for memory analyzing... – Taruni May 23 '11 at 08:08
-
Maybe, but MAT is the most popular I think and I've worked only with it. – Michael May 23 '11 at 09:31
-
-
Actually i want to know memory leak for a particular project or activity how would i load a particular project for memory leak – Taruni May 21 '11 at 09:59
-
while using DDMS mode i am getting the following error::: hprof: can't open /sdcard/profileit.ImageDemo.hprof-hptemp: Permission denied. – Taruni May 21 '11 at 10:07
Write to hprof fails when you have not used android.permission.WRITE_EXTERNAL_STORAGE. As a special case when you are testing on device, check if your SD card is connected in Charge ONLY mode otherwise you wont have write access on SD Card

- 743
- 8
- 16
Install MAT.
Go to Tools->Android ->Android device monitor(DDMS)
In the top left side under Devices,select the project name and click Update Heap.
Then Click Dump HPROF File and saved it in desktop.
Then run the Command prompt and point out the Android-sdk directory.
For an Example: hprof-conv is located in E directory. So run the command as
cd android/sdk/platform-tools
.Then finally run this command by referring this doc to convert this file format to read it in MAT.
E:\Android\sdk\platform-tools>
hprof-conv "C:\Users\Steve\Desktop\yourfilename.hprof" "C:\Users\Steve\Desktop\leakage.hprof"
Now your file will converted to leakage.hprof.check this file and open it in MAT.
Edit: Click details,then it will show the class names.In that Left Click -> Path To GC Roots ->With all references
.Then it shows the class name.

- 9,899
- 16
- 90
- 137
Square open sourced a memory analysis tool: LeakCanary.
The core of the LeakCanary is MAT.

- 967
- 12
- 15
I'd recommend taking a look at Leak Canary. It's not a memory analyzer per se, but more a leak detector. Just use your app, open and close activities and let the library do it's job. It will even tell you about where the leak occured. Just give the leak analyzer some time to do its work after the leak occured - it usually takes around 2 minutes or more until the source of the leak has been found.

- 3,680
- 6
- 36
- 60
Please update to Android studio version 1.4
or 1.5
.
In this version, android has supported new tool its called Analyzer Task
It is very useful to avoid memory leak.

- 36,608
- 11
- 63
- 88

- 410
- 6
- 6