Android memory

The following pages provide information about improving your app's use of memory.

General memory guidance

Memory overview
Explains core Android memory architecture, RAM constraints, and how the operating system balances processes using the Low Memory Killer (LMK).
Memory management
Outlines developer best practices for releasing resources across component lifecycles, avoiding leaks, and managing memory when transitioning between process states.
Understanding and troubleshooting Android memory
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.

Area specific optimizations

Games memory overview
Details memory budgeting, native allocation handling, and graphic asset management guidance tailored specifically for apps using game engines.
Optimizing bitmap images
Demonstrates how to size, decode, and cache bitmap assets efficiently within image libraries.
Manage and diagnose WebView memory
Explains the WebView multi-process memory model, describes how to properly manage its lifecycle to prevent leaks, and provides practical workflows for diagnosing memory issues.
R8 code optimization
Explains how to leverage R8 to reduce APK size, metadata overhead, and runtime memory consumption.

Local memory debug tools

Android Studio tools
Provides real-time heap inspection, memory allocation tracking, and leak detection workflows directly inside the IDE.
Perfetto Heap Dump Explorer
Offers deep visual analysis of native and Java or Kotlin heap dumps to isolate retained object trees and anonymous memory allocations.
Capture a system trace on device
Shows how to record on device system level traces to address performance-related bugs in your app.
Debugging memory usage on Android
Teaches how to understand Linux memory management and use tools like dumpsys meminfo, Perfetto, native heap profiles, and heap dumps to track memory usage and identify leaks.

Production level memory tools

Android vitals: Memory usage (anonymous RSS + swap)
Android vitals shares your app's production memory usage broken down by the process states foreground, foreground service, and background service.
Android vitals: Bitmap memory usage
Android vitals provides metrics on an app's bitmap memory footprint by aggregating data from Android devices.
Android vitals: DEX code optimization
Android vitals can alert you when your app's DEX code optimization levels are low. This includes obfuscation, shrinking, and optimization for apps and games that use R8.
Crashlytics 20.1.0
Surfaces production Out-Of-Memory (OOM) exceptions and memory limiter kills with diagnostic context to prioritize and fix field crashes.
ProfilingManager
Advanced API that lets apps programmatically collect and upload production heap dumps and heap profiles from live user sessions.

Additional resources

For more information about memory, see the following additional resources:

Blog posts

Videos