How rudjigames/mtuner works
1. What this repo builds
MTuner is split into two major runtime sides: a capture side that runs with the profiled application and records allocation history, and a desktop analysis side that opens the resulting capture and visualizes it. The desktop app is Qt-based and is currently functional on Windows; the capture SDK is designed to work more broadly.
2. Top-level code layout
The repository is organized around src/MTuner for the GUI application, src/libs for reusable support libraries, and src/tools for auxiliary capture/injection binaries. 3rd/unordered_dense is a vendored third-party dependency. The rest of the repo is mostly build scripts, resources, and localization assets.
3. Capture pipeline
The capture side centers on rmem-style allocator interception. It records every alloc, realloc, and free together with call stacks, thread IDs, heap/allocator identity, tags, sizes, and timestamps. The README indicates two deployment modes: Windows injection into an existing process, or SDK linking into the target application.
4. Capture file boundary
The output of the capture side is a portable .MTuner file, which is essentially a time-ordered history of memory operations. The capture path is optimized for low overhead: operations are serialized into compact records and written with LZ4 compression on a background thread.
5. Loader and in-memory model
Inside the desktop app, the loading boundary is handled by src/MTuner/src/loader/* and related classes such as capturecontext, binloaderview, and mtunerlib. These components parse the capture file, reconstruct the operation stream, and build the in-memory analysis model used by the rest of the UI.
6. Analysis layer
After loading, the app computes aggregate structures used for queries and drill-down: allocation statistics, grouped views, stack-trace trees, tag trees, module/thread/heap breakdowns, and the “Insights” findings. The design is explicitly history-based, so analysis is done over the whole timeline rather than a single live heap snapshot.
7. Visualization/UI shell
mtuner.cpp, mtunermain.cpp, centralwidget, and the many *.ui files define a dockable Qt application with multiple specialized views. The UI includes timeline graphs, histograms, treemaps, stack traces, hotspots, modules, threads, heaps, source, project management, operations lists/search, and the new Insights tab.
8. Visualization widgets as separate subsystems
The visual components are implemented as distinct widgets such as graph*, histogram*, treemap*, stacktrace*, stacktreewidget, hotspots, insightswidget, and sourceview. This separation matters architecturally: each view consumes the same loaded capture model but presents a different projection of the memory history.
9. Symbol resolution boundary
src/libs/rdebug and classes like symbolstore provide the symbol-resolution layer. On Windows this relies on PDB/DIA and the Microsoft public symbol server; for GCC/Clang toolchains it uses addr2line/nm. That resolution feeds stack traces, source links, and navigation from findings back into code.
10. Capture/injection tools
src/tools/MTunerCmd, MTunerDLL, and MTunerInject are supporting binaries for command-line control, injection, and runtime support. They form the operational boundary between the desktop analyzer and the profiled process, especially for the Windows injection workflow.
11. Shared support libraries
src/libs/rbase, rmem, rg_memory, rdebug, and rqt look like the reusable substrate for memory utilities, capture/runtime logic, debugging/symbol resolution, and Qt integration. These libraries reduce duplication between the desktop app and the capture-related tools.
12. Build and packaging architecture
The project is built with GENie/zidar and requires Qt plus Lua during generation. The repo includes scripts for Visual Studio 2022 and MinGW generation, AppVeyor CI config, and packaging scripts. Resources include fonts, icons, translations, and Qt resource files, which are all part of the shipped desktop application.
Main entry points: rmem rmem SDK · mtuner.cpp MTuner · capturecontext.cpp Capture model · graph.cpp Analysis views
Components 19
Desktop analyzer
Qt application for loading and exploring capture files
- MTuner · Main analysis application shell and entrypoint
src/MTuner/src/mtuner.cpp - Main entry · Application startup and main window bootstrap
src/MTuner/src/mtunermain.cpp - Workspace · Dockable central workspace hosting the major views
src/MTuner/src/centralwidget.cpp - Loader · Loads MTuner files and reconstructs the operation stream
src/MTuner/src/loader/binloader.cpp - Capture model · In-memory capture context and history-based analysis state
src/MTuner/src/capturecontext.cpp - Analysis views · Timeline, histograms, treemap, stack, hotspots, and insights projections
src/MTuner/src/graph.cpp - Symbols · Resolves stacks and source locations across toolchains
src/MTuner/src/symbolstore.cpp - Project tools · Project management, search, operations, and source navigation
src/MTuner/src/projectsmanager.cpp
Capture runtime
Injection and SDK-side recording of memory operations
- rmem SDK · Allocator interception and low-overhead memory event recording
src/libs/rmem - Injection · Windows injection and runtime hookup into profiled processes
src/tools/MTunerInject - MTunerCmd · Command-line control and operational helper for capture workflows
src/tools/MTunerCmd - MTunerDLL · Supporting DLL for capture or injection deployment
src/tools/MTunerDLL
Shared libraries
Reusable support libraries used across analyzer and tools
Build & packaging
Generation, packaging, and release support
- Genie scripts · Build generation logic and project setup scripts
src/MTuner/scripts/genie.lua - Packaging · Build, packaging, and CI automation scripts
scripts/MTunerPack.bat
Other components
- unordered_dense · Third-party dense hash map dependency
3rd/unordered_dense
Connections 21
- MTuner → Main entry: starts at · Application entrypoint initializes the desktop app
- Main entry → Workspace: hosts · Main window embeds the dockable workspace
- MTuner → Loader: opens MTuner · Loads capture files into the analysis pipeline
- Loader → Capture model: builds · Reconstructs the in-memory capture model from the file stream
- Capture model → Analysis views: feeds · Provides the shared model consumed by visual projections
- Capture model → Project tools: exposes · Backs operations, search, and navigation workflows
- Capture model → Symbols: resolves through · Connects stacks and findings to source and symbols
- Analysis views → Symbols: drills into · Stack and source views depend on resolved symbols
- Analysis views → Workspace: rendered in · Major analysis widgets live inside the main workspace
- Project tools → Workspace: integrated in · Workflow widgets are surfaced in the dockable shell
- Injection → rmem SDK: deploys · Injection path activates the capture runtime in target processes
- MTunerCmd → rmem SDK: controls · Command-line tooling supports the capture workflow
- MTunerDLL → rmem SDK: supports · DLL boundary participates in runtime capture deployment
- rmem SDK → Loader: emits files for · Serialized memory history becomes the MTuner capture file
- rdebug → Symbols: provides · Shared debug/symbol infrastructure underpins resolution
- rbase → rmem SDK: supports · Common utilities reused by runtime components
- rg_memory → rmem SDK: supports · Memory-oriented helpers shared by capture code
- rqt → MTuner: supports · Qt helper layer used by the desktop application
- Genie scripts → MTuner: generates · Build generation creates the application projects
- Packaging → MTuner: packages · Release scripts assemble the desktop application
- unordered_dense → rmem SDK: dependency · Vendored hash container used by internal components