Rust Memory analysis tool
⚓ Rust 📅 2026-05-20 👤 surdeus 👁️ 2Hi everyone,
I previously developed a Rust memory analysis tool, which is now available on crates io . I'm not here to promote the project, but rather to gather your feedback. Below is some data the tool can track:
Basic Allocation Information
-
Allocation/Release Events
- Pointer Address
- Allocation Size
- Thread ID
- Timestamp
-
Rust Variable-Level Information
- Variable Name
- Type Name
- Source File
- Line Number
- Module Path
- Explicitly Collected via the
track!Macro
-
Standard Library Type Semantics
Vec<T>/String/Box<T>: Tracked as the actual heap ownerHashMap/BTreeMap/VecDeque: Tracked as container metadata- Ordinary value types: Tracked as non-heap metadata
-
Arc/RC Shared Ownership
- Records the stack pointer of the smart pointer itself
- Records the heap pointer it points to
- In the post-analysis phase, groups are based on the same heap_ptr to identify possible clone/shared ownership relationships
- Does not rely on hard-coded ArcInner internal layout
-
Multithreading-related data:
- Allocation behavior of each thread
- Concurrency tracking events
- Active allocations
- Statistics such as peak memory/active memory
- Internal use of SegQueue, DashMap, and atomic counters to reduce lock contention
-
Async/task attribution
- Task ID
- Task hierarchy
- Memory usage per task
- Context needs to be explicitly established via task scope/tracked task
-
Unsafe/FFI memory passport
- Unsafe allocation
- FFI allocation, e.g., malloc
- Handover to FFI
- Freed by foreign code
- Reclaimed by Rust
- Potential leak/invalid free/double free candidate
- Recording cross-boundary memory lifecycle using a memory passport
-
Analysis and Export
- Leak detection
- Ownership/relation inference
- Memory timeline
- JSON export
- HTML dashboard
In short, the data collection strategy is layered:
- The underlying layer captures actual allocation/release events via GlobalAlloc;
- Variable-level information is explicitly supplemented using the
track!macro and the Trackable trait; - Scenarios such as Arc/Rc, container, and unsafe/FFI are identified through additional metadata and post-analysis;
- Rust semantics that cannot be directly observed at runtime are marked as inferences or candidate relationships, rather than being treated as absolute facts.
Partial example images of memory passport:
My idea is to differentiate it as much as possible from existing memory analysis tools. or give me some front-end suggestions? I have a lot of collected data, but I don't know how to visualize it. I promise the project is 100% open source and free.
Kind regards,
Tim
1 post - 1 participant
🏷️ Rust_feed

