Android-App-Memory-Analysis
中文版本 | English Version
A toolkit for comprehensive Android application memory analysis, featuring two primary analysis tools for smaps and hprof files.
Core Features
- SMAPS Analysis: Parses
/proc/pid/smapsfiles to analyze native memory, system memory, and memory-mapped files. It supports all Android versions from 4.0 to 16+ and requires root access. - HPROF Analysis: Parses Java heap dump (
.hprof) files to analyze Java objects, detect memory leaks, and identify large memory consumers. It works on all Android versions without requiring root access.
Quick Start
This repository has been simplified to provide a clear, cross-platform entry point through a single Python script: analyze.py.
Prerequisites
- Python 3.6+
- Android SDK with
adbin your PATH
Usage
The main script analyze.py provides two commands: hprof and smaps.
Analyze an HPROF file: Use the
hprofcommand and provide the path to your.hproffile. Sample files are in thedemo/hprof_sampledirectory.python3 analyze.py hprof demo/hprof_sample/heapdump-20250921-122155.hprofAnalyze a smaps file: Use the
smapscommand and provide the path to yoursmapsfile. Sample files are in thedemo/smaps_sampledirectory.python3 analyze.py smaps demo/smaps_sample/2056_smaps_file.txt
Analysis Tools
This repository contains the following core analysis tools located in the tools/ directory:
hprof_parser.py: A detailed parser for Java HPROF files.smaps_parser.py: A comprehensive parser for processsmapsfiles.memory_analyzer.py: A script that can combine analysis from both HPROF and smaps, though the primary entry point is nowanalyze.sh.
For advanced use cases, you can run these scripts directly. For example:
python3 tools/hprof_parser.py -f demo/hprof_sample/heapdump-20250921-122155.hprof
Documentation
For a deeper understanding of memory analysis concepts and tool outputs, please refer to the documentation in the docs/ directory.
Contributing
Contributions are welcome. Please feel free to submit pull requests or open issues.
