Tencent/loli_profiler

Memory instrumentation tool with CI and AI support for android app&game developers.

TL;DR

LoliProfiler is an open‑source memory‑profiling suite for Android apps. It captures native heap allocations, shows call‑stacks, treemaps, timelines and screenshots, and lets you compare two runs. It ships a graphical UI (built with Dear ImGui) and a headless CLI, plus a Python package for querying the saved data.

What it does

Component Function
LoliProfilerImGui Desktop GUI – launch or attach to an Android app, view live or saved captures, export .loli files.
LoliProfilerCLI Head‑less capture, export to plain‑text or SQLite, symbolise offline, compare captures from the command line.
LoliProfilerCompare Dedicated UI for loading two captures side‑by‑side with dockable Base, Comparer and Diff panels.
agentcli (Python) Small library that opens the SQLite snapshot (.db) and lets scripts query the call‑tree (loli command).

During a capture you can keep all allocation records or only those still alive when you stop. The UI lets you switch between the two views. Symbol names are shown when you provide the app’s debug‑symbol files.

How to get it running

  1. Build – From the repo root run python scripts/build.py. The script presents an interactive menu to compile the GUI, CLI, Android hooks and package a release zip. It will download the Android SDK/NDK if you confirm.
  2. Prerequisites – See docs/BUILD.md for required compilers, CMake, and platform‑specific notes (Windows/macOS/Linux).
  3. Quick start – Follow docs/QUICK_START.md (or the Chinese version) to:
    • Build the tools.
    • Connect a device via ADB.
    • Launch LoliProfilerImGui to attach to an app, capture, and explore the results.
  4. Head‑less use – Run LoliProfilerCLI with flags like --log-file profiler.log --log-level debug to capture without a UI and export data.
  5. Comparison – Use LoliProfilerCompare or the CLI’s compare mode to load two .loli files and see differences in allocation patterns.
  6. Scripting – Install the agentcli package (pip install . inside agentcli) and use the loli command or import the library to query the SQLite snapshot.

Who might find it useful?

  • Android developers who need to understand native memory usage, spot leaks, or optimise allocation patterns.
  • Game developers targeting Android, since the docs include a section on integrating the profiler with game engines.
  • Performance engineers who want to compare two builds or runtime configurations side‑by‑side.
  • Researchers building tools around Android memory behaviour; the Python agent makes it easy to write custom analyses.

Limitations / gotchas

  • Only native allocations are captured (C/C++); Java‑level allocations are out of scope.
  • Symbol resolution requires the app’s native libraries built with debug symbols.
  • The UI depends on Dear ImGui/SFML, so it runs on desktop OSes but not directly on the device.
  • Capture overhead is non‑zero; keep an eye on the “Console” tab timings.

License & credits

The project is MIT‑licensed (see LICENSE). It bundles several permissively‑licensed third‑party libraries (Dear ImGui, SFML, SQLite, LZ4, etc.) and builds on a fork of an earlier loli_profiler implementation by shuchangliu.


All information above is taken directly from the repository’s README.

Related

  • Project
  • Project
  • Project
  • Project