Below are steps to setup the MAT.
1. To install MAT, open Eclipse, click on Help -> Install New Software ->
2. Enter "Add" button and enter "Name" and "Location" into the dialog box
Name: MAT Location: http://download.eclipse.org/mat/1.2/update-site/
4. To allow the application to generate hprof file, right click on the project, Run As -> Run Configurations, select "Arguments" tab and enter "-XX:+HeapDumpOnOutOfMemoryError" into "VM arguments" text box.
5. When the Java/Android app crashes, hrof will be generated.
6. Double click on the hprof file, MAT will be launched and select "Leak Suspect Report" option and click on "Finish" button.
7. Leaks Suspect report will be generated.
If you encounter "Parsing heap dump" while opening the hprof file, open the eclipse.ini file which is located at Eclipse home folder. Increase the -Xms and -Xmx size (until the message disappear), refer to the highlighted paragraph as shown below:-
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120522-1813
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
1024m
--launcher.defaultAction
openFile
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
1024M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-Xms8192m
-Xmx10240m
To produce Android hprof file for MAT analysis, launch the DDMS, select device follow by running application. Click on dump HPROF file, the MAT analyzer will be launched.