Memory Usage in Android

18
Investigating Your RAM Usage

Transcript of Memory Usage in Android

Page 1: Memory Usage in Android

Investigating Your RAM Usage

Page 2: Memory Usage in Android

How To Analyse App’s Memory Usage?

Interpreting Log Messages

Viewing Heap Updates

Tracking Allocations

Viewing Overall Memory Allocations

Capturing a Heap Dump

Page 3: Memory Usage in Android

Interpreting Log Messages

Page 4: Memory Usage in Android

Dalvik Log Messages

D/dalvikvm: <GC_Reason> <Amount_freed>, <Heap_stats>, <External_memory_stats>, <Pause_time>

In Dalvik (but not ART), every GC prints the following

information to logcat:

D/dalvikvm( 9050): GC_CONCURRENT freed 2049K, 65% free 3571K/9991K, external

4703K/5261K, paused 2ms+2ms

Example:

Page 5: Memory Usage in Android

ART Log Messages

ART includes the following information in its garbage

collection log messages:

I/art: <GC_Reason> <GC_Name> <Objects_freed>(<Size_freed>) AllocSpace Objects, <Large_objects_freed>(<Large_object_size_freed>) <Heap_stats> LOS objects, <Pause_time(s)>

Example: I/art : Explicit concurrent mark sweep GC freed 104710(7MB) AllocSpace objects, 21(416KB) LOS objects, 33% free, 25MB/38MB, paused 1.230ms total 67.216ms

Page 6: Memory Usage in Android

Viewing Heap Updates

Page 7: Memory Usage in Android

Memory Monitor in Android StudioDump Java Heap icon ( ) in the Memory Monitor toolbar

Page 8: Memory Usage in Android

Device Monitor

From your <sdk>/tools/ directory, launch the monitor tool.

Page 9: Memory Usage in Android

Tracking Allocations

Page 10: Memory Usage in Android

Allocation Tracker

Page 11: Memory Usage in Android

Allocation Tracker in Device Monitor

Page 12: Memory Usage in Android

Viewing Overall Memory Allocations

Page 13: Memory Usage in Android

Android Debug Bridge (ADB)

adb shell dumpsys meminfo <package_name|pid> [-d]

Usage:

adb shell dumpsys meminfo com.google.android.apps.maps -d

Example:

Page 14: Memory Usage in Android

Gmail App dumpsys Stats

Page 15: Memory Usage in Android

Capturing a Heap Dump

Page 16: Memory Usage in Android

Eclipse Memory Analyzer Tool

Page 17: Memory Usage in Android

Reference

Android Developer Website

Page 18: Memory Usage in Android

Thank You