Java Heap memory leak
Start DDMS from:
C:\Program Files (x86)\Android\android-sdk\tools\ddms.bat
Select the faulting App.
Click on the "Show heap updates" green icon.
Open the "VM Heap" tab, click on "Cause GC" to clean Heap. Look at allocations.
After some cycles, click on "Dump HPROF file" green icon.
Concert the file to Java format using:
"C:\Program Files (x86)\Android\android-sdk\tools\hprof-conv.exe" <hprof> <hprof converted>
Parse the converted Hprof file using Memory Analyser:
Note:
- Shallow memory: own object memory
- Retained memory: dominated sub objects size
Select one suspicious leak in the Dominator Tree, then Right Click / Path to GC Roots / exclude weak references
Tricks:
- MainActivity.*: should have only 1 instance
- sub-objects should be non static
- sub-classes should be static
浙公网安备 33010602011771号