URL and Link repository

Monday, January 21, 2013

Android, Eclipse, Memory Analyzer Tool (MAT)

Been a little while since I last needed to analyze memory leaks on an Android application written in Java and compiled through Eclipse.

Things have changed in both Eclipse and MAT, so I am listing my current steps here for all to enjoy.


1. Fire up Eclipse Indigo with Java 6 +
2. In Eclipse, Select [Help] | [Install new Software]
3. Add http://download.eclipse.org/mat/1.2/update-site/.
4. Select All []IDE and []Stand Alone
5. In Eclipse top menu bar, select [Window] | [Preferences] | [Android] | [DDMS]
a. HPROF Action: "open in Eclipse"
6. In Eclipse top menu bar, select [Window] | [Preferences] | [Plug-in Development] | [Target Platform]
7. Highlight Active Platform, then press [Edit].
8. Click [Arguments] tab: Type -XX:+HeapDumpOnOutOfMemoryError in VM Arguments,[Finish]
9. A heap dump is written on the first Out Of Memory Error.
10. Run project with emulator as the process must be on the local machine.
11. In Eclipse top menu bar, select [Window] | [Open Perspective] | [Other] | [Memory Analysis]
12. From inside the Memory Analysis perspective select [File] | [Acquire Heap Dump]
13. [Configure] | Select HPROF -jmap dump | -jdkhome = C:\Java\jdk1.7.0
14. [Next] | Select HPROF -jmap dump | [Finish]
15. Follow remaining prompts in Eclipse.

Compare and augment the previous steps with BonitaSoft.org

Also, try to perform these steps on a machine greater than an Acer Aspire netbook with 1GB of RAM. Otherwise, the process could take days.

No comments:

Post a Comment