{"id":50392589,"url":"https://github.com/Gracker/Android-App-Memory-Analysis","last_synced_at":"2026-06-16T10:01:01.323Z","repository":{"id":63409586,"uuid":"250508412","full_name":"Gracker/Android-App-Memory-Analysis","owner":"Gracker","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-10T07:30:18.000Z","size":27758,"stargazers_count":149,"open_issues_count":2,"forks_count":36,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-02-10T13:35:00.467Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gracker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-03-27T10:47:16.000Z","updated_at":"2026-02-10T07:30:23.000Z","dependencies_parsed_at":"2025-03-14T11:37:27.897Z","dependency_job_id":null,"html_url":"https://github.com/Gracker/Android-App-Memory-Analysis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Gracker/Android-App-Memory-Analysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gracker%2FAndroid-App-Memory-Analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gracker%2FAndroid-App-Memory-Analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gracker%2FAndroid-App-Memory-Analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gracker%2FAndroid-App-Memory-Analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gracker","download_url":"https://codeload.github.com/Gracker/Android-App-Memory-Analysis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gracker%2FAndroid-App-Memory-Analysis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34400456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-30T19:00:29.697Z","updated_at":"2026-06-16T10:01:01.317Z","avatar_url":"https://github.com/Gracker.png","language":"Python","funding_links":[],"categories":["🛠 开发工具"],"sub_categories":[],"readme":"# Android App Memory Analysis\n\n[中文版本](./README_zh.md) | English Version\n\nA comprehensive toolkit for Android application memory analysis, featuring **one-click live dump** from connected devices and **multi-source correlation analysis** for deep memory insights.\n\n## Features\n\n### Core Capabilities\n\n| Feature | Description | Root Required |\n|---------|-------------|---------------|\n| **Live Dump** | One-click dump all memory data from connected device | Partial (see below) |\n| **Panorama Analysis** | Multi-source correlation (meminfo + gfxinfo + hprof + smaps) | No |\n| **HPROF Analysis** | Java heap analysis, leak detection, large object tracking | No |\n| **SMAPS Analysis** | Native memory mapping, detailed memory classification | Yes |\n| **Meminfo Analysis** | Parse `dumpsys meminfo` including Native Allocations | No |\n| **Gfxinfo Analysis** | Parse `dumpsys gfxinfo` for GPU/Graphics stats | No |\n\n### Root Permission Requirements\n\n| Data Source | Without Root | With Root |\n|-------------|--------------|-----------|\n| dumpsys meminfo | ✅ Full data | ✅ Full data |\n| dumpsys gfxinfo | ✅ Full data | ✅ Full data |\n| hprof dump | ⚠️ Debuggable apps only | ✅ All apps |\n| smaps | ❌ Permission denied | ✅ Full data |\n\n## Quick Start\n\n### Prerequisites\n\n- Python 3.8+\n- ADB (Android Debug Bridge) in your PATH or in `tools/` folder\n- Connected Android device with USB debugging enabled\n\n### Android 17 / API 37 Compatibility Notes\n\n- The Demo APK now uses `compileSdk = 37`, `targetSdk = 37`, and demo version `1.1.0`, while keeping Android 16 edge-to-edge handling and 16 KB page-size alignment for native `.so` output.\n- The toolkit supports Android 4.0 through Android 17+ input formats; parsing logic includes newer allocator and mapping names such as Scudo, GWP-ASan, DMA-BUF, stack/TLS, and JIT caches.\n- Panorama analysis now treats `smaps` as a first-class process-mapping source. It can run with smaps-only input and reports smaps PSS/SwapPSS, native allocator, graphics, DMA-BUF, code, stack, and top mapping evidence without overwriting `dumpsys meminfo` metrics.\n- Android 17 app memory limits are an Android 17 all-app runtime behavior on supported devices. Live dump now archives `exit_info.txt`, `memory_limiter_status.txt`, package UID, process lists, Android release/sdk, build fingerprint, and page size before requiring PID-dependent artifacts.\n- For `smaps` collection, use fallback order for better device compatibility:\n  1) `adb shell cat /proc/\u003cpid\u003e/smaps`\n  2) `adb shell su -c \"cat /proc/\u003cpid\u003e/smaps\"`\n  3) `adb shell su 0 cat /proc/\u003cpid\u003e/smaps`\n- `pidof` is preferred for PID lookup, and `ps -A` parsing is used as fallback.\n- See [Android 17 / API 37 Adaptation Review](./docs/en/android_17_adaptation_review.md) for the Android 17 build, memory-limiter, runtime, and evidence checklist.\n- See [Android 16 / API 36 Adaptation Review](./docs/en/android_16_adaptation_review.md) for the Android 16 and 16 KB page-size baseline.\n\n### Installation\n\n```bash\ngit clone https://github.com/Gracker/Android-App-Memory-Analysis.git\ncd Android-App-Memory-Analysis\n```\n\n### Usage\n\n#### One-Click Live Dump \u0026 Analysis (Recommended)\n\n```bash\n# List running apps on connected device\npython3 analyze.py live --list\n\n# Dump and analyze a specific app\npython3 analyze.py live --package com.example.app\n\n# Quick mode (skip hprof for faster results)\npython3 analyze.py live --package com.example.app --skip-hprof\n\n# Dump only (no analysis)\npython3 analyze.py live --package com.example.app --dump-only -o ./dumps\n```\n\n#### Panorama Analysis (Multi-Source Correlation)\n\n```bash\n# Analyze existing dump directory\npython3 analyze.py panorama -d ./dumps/com.example.app_20231225_120000\n\n# Analyze individual files\npython3 analyze.py panorama -m meminfo.txt -g gfxinfo.txt -H app.hprof -S smaps.txt\n\n# Analyze privileged process mappings only\npython3 analyze.py panorama -S smaps.txt --json -o smaps_panorama.json\n```\n\n#### Individual File Analysis\n\n```bash\n# Analyze Java heap (HPROF)\npython3 analyze.py hprof demo/hprof_sample/heapdump_latest.hprof.gz\n\n# Analyze native memory (smaps)\npython3 analyze.py smaps demo/smaps_sample/smaps\n\n# Analyze meminfo\npython3 analyze.py meminfo dump/meminfo.txt\n\n# Analyze gfxinfo\npython3 analyze.py gfxinfo dump/gfxinfo.txt\n\n# Traditional combined analysis (HPROF + smaps)\npython3 analyze.py combined -H demo/hprof_sample/heapdump_latest.hprof.gz -S demo/smaps_sample/smaps\n\n# Enhanced combined analysis (meminfo-aware, mtrack included)\npython3 analyze.py combined --modern --hprof demo/hprof_sample/heapdump_latest.hprof.gz --smaps demo/smaps_sample/smaps --meminfo demo/smaps_sample/meminfo.txt --json-output report.json\n\n# One-command demo shortcut (built-in hprof+smaps+meminfo)\npython3 analyze.py combined --demo --json-output demo_report.json\n```\n\nNotes:\n- `combined` defaults to legacy mode (`combined_analyzer.py`) unless `--modern`, `--meminfo`, `--pid`, `--json-output`, or `--demo` is provided.\n- In modern mode with `-p/--pid`, the tool auto-collects `smaps` and tries to collect `dumpsys meminfo -d`.\n- The bundled demo HPROF is committed as `heapdump_latest.hprof.gz` to avoid large-file push limits. The unified `analyze.py` entry point reads `.hprof.gz` directly. If an old sample path ending in `.hprof` is missing but a sibling `.hprof.gz` exists, it automatically falls back to the packaged sample.\n\n## What Gets Analyzed?\n\n### Panorama Analysis Output\n\nThe panorama analysis provides a comprehensive view of memory usage:\n\n```\n================================================================================\n                     Android 内存全景分析报告\n================================================================================\n\n📊 Memory Overview:\n------------------------------\n  Total PSS:        245.67 MB\n  Java Heap:        89.34 MB\n  Native Heap:      34.21 MB\n  Graphics:         45.67 MB\n  Code:             23.78 MB\n  Stack:            1.23 MB\n\n🖼️ Bitmap Deep Analysis:\n------------------------------\n  Bitmap (malloced):     27 objects    6.78 MB\n  Bitmap (nonmalloced):   8 objects   11.59 MB\n  GPU Cache:             15.34 MB\n  GraphicBuffer:         12.45 MB\n\n📈 Native Memory Tracking:\n------------------------------\n  Tracked Native:        28.45 MB (83.2%)\n  Untracked Native:       5.76 MB (16.8%)\n\n  ⚠️ Warning: Significant untracked Native memory detected\n\n🎨 UI Resources:\n------------------------------\n  Views: 1,234\n  ViewRootImpl: 3\n  Activities: 5\n  WebViews: 0\n```\n\n### Key Analysis Features\n\n1. **Bitmap Correlation**: Links Java Bitmap objects to Native pixel memory\n2. **Native Memory Tracking**: Identifies tracked vs untracked Native allocations\n3. **GPU Memory Analysis**: GraphicBuffer and GPU cache usage\n4. **UI Resource Counting**: View hierarchy and Activity leak detection\n5. **Anomaly Detection**: Automatic warnings for potential issues\n\n## Project Structure\n\n```\nAndroid-App-Memory-Analysis/\n├── analyze.py              # Main entry point\n├── tools/\n│   ├── hprof_parser.py     # HPROF file parser\n│   ├── smaps_parser.py     # smaps file parser\n│   ├── meminfo_parser.py   # dumpsys meminfo parser\n│   ├── gfxinfo_parser.py   # dumpsys gfxinfo parser\n│   ├── panorama_analyzer.py # Multi-source correlation analyzer\n│   ├── combined_analyzer.py # HPROF + smaps combined analyzer\n│   ├── memory_analyzer.py  # Enhanced combined analyzer with meminfo/mtrack correlation\n│   ├── live_dumper.py      # Live dump from device\n│   ├── hprof_dumper.py     # HPROF dump utility\n│   └── adb                 # ADB binary (optional)\n├── demo/\n│   ├── hprof_sample/       # Latest sample HPROF + analysis output\n│   ├── smaps_sample/       # Latest sample smaps/meminfo/showmap/gfxinfo + reports\n│   └── memory-lab/         # Demo APK project used to regenerate sample datasets\n├── docs/\n│   ├── en/                 # English documentation\n│   └── zh/                 # Chinese documentation\n└── pic/                    # Images for documentation\n```\n\n## Documentation\n\nFor detailed guides on interpreting analysis results:\n\n- [English Learning Path](./docs/en/README.md)\n  - [Analysis Results Guide](./docs/en/analysis_results_interpretation_guide.md)\n  - [Meminfo Interpretation](./docs/en/meminfo_interpretation_guide.md)\n  - [SMAPS Interpretation](./docs/en/smaps_interpretation_guide.md)\n  - [Android 17 / API 37 Adaptation Review](./docs/en/android_17_adaptation_review.md)\n  - [Android 16 / API 36 Adaptation Review](./docs/en/android_16_adaptation_review.md)\n  - [Teaching Playbook](./docs/en/teaching_playbook.md)\n\n- [Chinese Learning Path](./docs/zh/README.md)\n  - [分析结果解读指南](./docs/zh/analysis_results_interpretation_guide.md)\n  - [meminfo 解读](./docs/zh/meminfo_interpretation_guide.md)\n  - [smaps 解读](./docs/zh/smaps_interpretation_guide.md)\n  - [Android 17 / API 37 适配 Review](./docs/zh/android_17_adaptation_review.md)\n  - [教学实践手册](./docs/zh/teaching_playbook.md)\n  - [Demo APK case study (Chinese)](./docs/zh/memory_lab_demo_case_study.md)\n\n## Data Sources\n\n| Data Source | Command | Information Provided |\n|-------------|---------|---------------------|\n| smaps | `cat /proc/\u003cpid\u003e/smaps` | Detailed memory mapping |\n| hprof | `am dumpheap \u003cpkg\u003e \u003cpath\u003e` | Java heap objects and references |\n| meminfo | `dumpsys meminfo \u003cpkg\u003e` | Summary + Native Allocations (Bitmap stats) |\n| gfxinfo | `dumpsys gfxinfo \u003cpkg\u003e` | GPU cache, GraphicBuffer, frame stats |\n\n## Related Tools\n\nThis toolkit complements these Android memory analysis tools:\n\n- **Android Studio Profiler**: Real-time memory monitoring\n- **LeakCanary**: Automatic memory leak detection\n- **MAT (Memory Analyzer Tool)**: Deep HPROF analysis\n- **Perfetto**: System-wide tracing\n\n## Contributing\n\nContributions are welcome! Please feel free to submit pull requests or open issues.\n\n## License\n\nThis project is open source. See LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGracker%2FAndroid-App-Memory-Analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGracker%2FAndroid-App-Memory-Analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGracker%2FAndroid-App-Memory-Analysis/lists"}