Memory is a critical and finite resource on Android devices. As an Android platform developer or OEM, understanding how memory works at every level—from the Java runtime down to the Linux kernel—is essential for building a performant and stable system.
This guide provides a comprehensive overview of Android memory architecture, the tools available for analysis, and hands-on exercises to help you identify and resolve memory-related issues.
After completing this guide, you will be able to:
dumpsys meminfo and showmap to quickly assess memory usage.heapprofd to profile both Java and native memory across the entire system.This guide is organized into the following sections, designed to be read sequentially:
meminfo, showmap, and procstats for rapid triage.heapprofd.To follow the hands-on exercises in this guide, you should have an Android device with root access connected to your development machine.
If you are using acloud:
You can create a virtual Cuttlefish device suitable for testing:
source build/envsetup.sh lunch aosp_cf_arm64_phone-trunk_staging-userdebug acloud create --build-target aosp_cf_arm64_phone-trunk_staging-userdebug --local-image
If you are using a physical device: Ensure your device is running a userdebug build, and enable USB debugging.
Ensure Root Access: Most of the tools used in this guide require elevated privileges. Verify your device is connected and rooted:
adb root adb wait-for-device
Start Here: Fundamental Concepts