3. Why Manage Memory?
• LRU app (lowmemkiller)
• Apps retaining large chunks of Memory.
• GC cycle is fast.
• OutOfMemory Exception
4. Garbage Collection
• Type of GC
• Reference counting
• Mark and Sweep
• Mark, Sweep and Compact.
• Android GC is of type. Mark and Sweep(Concurrent)
• Concurrent (Gingerbread and beyond)
6. Memory Leaks
• GC does not prevent memory leaks
• Reference to un-used objects lead to leaks
• Single reference can prevent large group of objects
from being collected
• Common leaks
• Long lived references to Activity/Context or View
objects
8. Heap Dumps
• Generate using:
• DDMS or IDE (Android Studio / Eclipse)
• Calling android.os.debug.dumpHprofData()
• Convert to standard HPROF format(if required):
• hprof-conv heap-original.hprof heap-converted.hprof
• Analyze with tools like Eclipse MAT