
Memory Leak Detector
https://github.com/bytedance/memory-leak-detector- Category
- Developer Tools
- Rank
- No. 921Tools index
- Pricing
- Open Source
- Type
- TOOL
- Builder
- bytedance
- GitHub
- 1.2k stars
- Latest release
- 0.2.1
- Date
About
ByteDance's Android native memory leak detector — pinpoints leaks in C/C++ code from production apps.
What it does
It instruments an Android process, records native allocation activity, and writes reports plus process memory maps. Developers can monitor the whole process or selected shared libraries, then run an offline Python analyzer to merge matching stacks, group suspected bytes, and resolve addresses against native symbols.
Why it's ranked here
The repository shows a practical end-to-end path from in-app capture to symbolized reports. It supports both code-driven and ADB broadcast control, and the README reports deployment across major ByteDance apps. The verdict is positive for specialized Android native diagnostics, tempered by manual setup and platform-specific analysis tooling.
What's good
Monitoring can target shared libraries by regular expression or cover the current process. Broadcast control permits capture without adding control code to the application workflow. Reports retain stack, allocation size, and count information, while offline analysis merges identical traces, groups totals by module, and caches symbol lookups.
Tradeoffs
The workflow requires writable device storage, appropriate permission, collected symbol files, and Android address-resolution tools on the analysis machine. The active symbolization path targets AArch64; the 32-bit ARM alternative is commented out. Configuration uses compact bit flags, and the supplied documentation gives examples without explaining each field in depth.
How to use it well
Use it when an Android team owns native libraries and can reproduce or capture suspicious growth inside a process. Keep matching unstripped symbols, trigger capture through application code or ADB, export the report, then symbolize it offline. It does not present itself as a managed Java or Kotlin heap profiler.
Technical notes+
library/src/main/cpp/Raphael.cpp initializes MemoryCache, selects inline or shared-object load proxies, clears prior output, prints cached data, and copies /proc/self/maps. library/src/main/cpp/xloader.cpp exposes nStart, nStop, and nPrint through JNI registration. library/src/main/xHook/xh_core.c scans mapped ELF objects and applies regex-selected symbol hooks, while library/src/main/xDL/xdl.c resolves dynamic and full symbol tables, including compressed .gnu_debugdata through library/src/main/xDL/xdl_lzma.c. library/src/main/python/raphael.py parses and merges traces, groups retained bytes, and invokes AArch64 addr2line; library/src/main/python/mmap.py categorizes mapped memory totals. build.gradle configures the Android Gradle plugin and JitPack repository.
Observed
- License
- Apache License 2.0 for the project; bundled source files also carry permissive third-party notices.
- Primary languages
- C and C++ native implementation, Java-facing JNI bindings, and Python analysis scripts.
- Packaging and install surface
- Android library distributed through JitPack and added as a Gradle dependency.
- Interfaces
- Java library controls, ADB broadcast controls, JNI native bindings, and Python command-line analyzers.
- Platform support
- Android API level 14 and later, according to the README badge.
- Capture scope
- Can monitor the current process or shared libraries selected by regular expression.
Read from README.md, build.gradle, library/src/main/xDL/xdl.c, library/src/main/python/mmap.py, library/src/main/xDL/xdl_lzma.c, library/src/main/xDL/xdl_util.c, library/src/main/xHook/xh_elf.c, library/src/main/xHook/xh_log.c, library/src/main/cpp/MapData.cpp, library/src/main/cpp/Raphael.cpp, library/src/main/cpp/xloader.cpp, library/src/main/xHook/xh_core.c, library/src/main/xHook/xh_util.c, library/src/main/python/raphael.py, library/src/main/unwind32/ptrace.c.
What it can do
Detect memory leaks in native Android code
C/C++ code in Android application → Memory leak detection report
Pinpoint exact locations of memory leaks
Native code with memory allocation issues → Specific file locations and line numbers of leaks
Analyze production application memory usage
Running Android production application → Memory usage analysis and leak identification
Monitor native memory allocation patterns
Active Android app processes → Memory allocation tracking data
Generate memory leak diagnostic reports
Detected memory issues and stack traces → Detailed diagnostic report with leak information
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.