heaptrack
Purpose
Guide agents through heaptrack for heap allocation profiling on Linux: recording allocation traces, analysing with heaptrack_print, identifying leaks and hotspots, and comparing runs.
Triggers
- "How do I find memory allocation hotspots in my C++ program?"
- "My program uses too much memory — how do I find where?"
- "How do I use heaptrack to detect memory leaks?"
- "What is heaptrack and how does it differ from Valgrind massif?"
- "How do I compare memory usage between two program versions?"
- "heaptrack_print output — how do I interpret it?"
Workflow
1. Installation
2. Basic usage
3. Build for better profiling
4. Interpreting heaptrack_print output
Key sections:
5. Filtering and analysis options
6. Comparing two runs
7. heaptrack vs Valgrind massif
Use heaptrack for most cases; use massif when you need platform portability or detailed snapshot comparison.
8. Integration with Rust
heaptrack works with Rust binaries when using the system allocator:
For heaptrack_print output reference and GUI usage, see references/heaptrack-analysis.md [blocked].
Related skills
- Use
skills/profilers/valgrindfor Memcheck (correctness) and massif (alternative heap profiler) - Use
skills/profilers/linux-perffor CPU profiling alongside memory profiling - Use
skills/rust/rust-profilingfor Rust-specific allocation profiling approaches - Use
skills/runtimes/sanitizers— ASan LeakSanitizer for leak detection without profiling overhead


