中文版本 | English Version
A toolkit for comprehensive Android application memory analysis, featuring two primary analysis tools for smaps
and hprof
files.
- SMAPS Analysis: Parses
/proc/pid/smaps
files 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.
This repository has been simplified to provide a clear, cross-platform entry point through a single Python script: analyze.py
.
- Python 3.6+
- Android SDK with
adb
in your PATH
The main script analyze.py
provides two commands: hprof
and smaps
.
-
Analyze an HPROF file: Use the
hprof
command and provide the path to your.hprof
file. Sample files are in thedemo/hprof_sample
directory.python3 analyze.py hprof demo/hprof_sample/heapdump-20250921-122155.hprof
-
Analyze a smaps file: Use the
smaps
command and provide the path to yoursmaps
file. Sample files are in thedemo/smaps_sample
directory.python3 analyze.py smaps demo/smaps_sample/2056_smaps_file.txt
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 processsmaps
files.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
For a deeper understanding of memory analysis concepts and tool outputs, please refer to the documentation in the docs/
directory.
Contributions are welcome. Please feel free to submit pull requests or open issues.