Process Stats: Understanding How Your App Uses Memory
Article Summary
Dianne Hackborn from the Android framework team reveals a hidden tool that exposes exactly how your app behaves when users aren't looking. Most developers are flying blind on background memory usage.
Android 4.4 KitKat introduced procstats, a system service that tracks app memory usage over time rather than just snapshots. This Google blog post explains why traditional task managers miss the real story and how procstats captures what's actually happening in the background.
Key Takeaways
- Procstats tracks memory use over time, not just instant snapshots
- Memory weight calculated as runtime multiplied by average PSS
- Tool reveals apps running in background without user awareness
- Process Stats UI available in Settings under Developer options
- PSS metric weights shared RAM across processes for accurate totals
Procstats gives developers a time-based view of background memory consumption, revealing inefficiencies that snapshot tools like traditional task managers completely miss.
About This Article
Developers couldn't see how apps actually behaved when running in the background. Task managers only showed memory snapshots at a single moment, which didn't capture what was really happening over time. This made it impossible to spot memory problems on low-RAM devices.
Google built the procstats service to watch all running processes continuously. It tracks how apps move between different states like Imp Fg, Imp Bg, Service, and Receiver modes, collecting memory samples throughout. This gives developers a real picture of how memory use changes over time.
With procstats, developers could finally measure background memory use accurately. They discovered the Clock app consumed almost 3x more RAM than Google Keyboard even though it ran less than half the time. This data directly helped Android 4.4's Project Svelte cut down memory usage.