/heaptrack
heaptrack memory profiler skill for Linux. Use when tracking heap allocations, finding memory leaks, measuring peak heap usage, identifying allocation hotspots, or comparing allocation behaviour between runs. Activates on queries about heaptrack, heap profiling, memory
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill heaptrack --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/heaptrack
Context preview
The summary Claude sees to decide when to auto-load this skill.
heaptrack memory profiler skill for Linux. Use when tracking heap allocations, finding memory leaks, measuring peak heap usage, identifying allocation hotspots, or comparing allocation behaviour between runs. Activates on queries about heaptrack, heap profiling, memory
SKILL.md
heaptrack.SKILL.mdname: heaptrack
description: heaptrack memory profiler skill for Linux. Use when tracking heap allocations, finding memory leaks, measuring peak heap usage, identifying allocation hotspots, or comparing allocation behaviour between runs. Activates on queries about heaptrack, heap profiling, memory allocation analysis, heaptrack_print, allocation hotspots, or memory leak detection with heaptrack.
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
# Ubuntu/Debian
sudo apt-get install heaptrack heaptrack-gui
# Fedora
sudo dnf install heaptrack
# Arch
sudo pacman -S heaptrack
# Build from source
git clone https://github.com/KDE/heaptrack.git
cmake -S heaptrack -B heaptrack-build -DCMAKE_BUILD_TYPE=Release
cmake --build heaptrack-build -j$(nproc)
2. Basic usage
# Profile a program (generates heaptrack.<prog>.<pid>.zst)
heaptrack ./myapp arg1 arg2
# Attach to running process
heaptrack --pid 12345
# Analyse the trace file
heaptrack_print heaptrack.myapp.12345.zst
# GUI analysis (if heaptrack-gui installed)
heaptrack_gui heaptrack.myapp.12345.zst
3. Build for better profiling
# Build with debug symbols (essential for readable backtraces)
cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
# Then profile
heaptrack ./build/myapp
4. Interpreting heaptrack_print output
heaptrack_print heaptrack.myapp.*.zst 2>/dev/null
Key sections:
total runtime: 2.34s
calls to allocation functions: 145,234 (62,064/s)
temporary allocations: 89,123 (38,087/s)
peak heap memory consumption: 45.23MB
peak RSS (including heap): 78.45MB
total memory leaked: 2.34MB
# Top allocation hotspots (by peak memory)
hotspot 1: 12.34MB peak
myapp::cache::Cache::insert(...)
at src/cache.cpp:142
...
# Top leaked allocations
leak 1: 2.34MB leaked in 1,234 allocations
myapp::connection::Connection::new(...)
at src/connection.cpp:67| Metric | Meaning | |--------|---------| | `total memory leaked` | Memory allocated but never freed | | `peak heap consumption` | Maximum live heap at any point | | `temporary allocations` | Allocated and freed within one call stack | | `calls to allocation functions` | Total malloc/new/realloc calls |
5. Filtering and analysis options
# Show top N hotspots
heaptrack_print -p 10 heaptrack.myapp.*.zst # top 10 hotspots
# Show flamegraph data
heaptrack_print -f heaptrack.myapp.*.zst > alloc.folded
flamegraph.pl alloc.folded > alloc.svg
# Show only leaked allocations
heaptrack_print -l heaptrack.myapp.*.zst
# Show allocations above threshold
heaptrack_print --min-cost 1048576 heaptrack.myapp.*.zst # >1MB only
# Short summary
heaptrack_print -s heaptrack.myapp.*.zst
6. Comparing two runs
# Record baseline
heaptrack ./myapp --config baseline.conf
mv heaptrack.myapp.*.zst before.zst
# Make changes, record again
heaptrack ./myapp --config new.conf
mv heaptrack.myapp.*.zst after.zst
# Compare (shows diff of hotspots)
heaptrack_print before.zst | head -20 > before.txt
heaptrack_print after.zst | head -20 > after.txt
diff before.txt after.txt
7. heaptrack vs Valgrind massif
| Feature | heaptrack | Valgrind massif | |---------|-----------|-----------------| | Overhead | ~2-3x | ~20x | | Output | Compressed trace + GUI | Text/ms_print | | Leak detection | Yes | Yes | | Peak tracking | Yes | Yes | | Temporal view | Yes (GUI) | Yes (ms_print) | | Platform | Linux only | Linux, macOS | | Needs recompile | No | No | | Call graph | Full stack traces | Full stack traces |
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:
// Rust: use system allocator so heaptrack can intercept
use std::alloc::System;
#[global_allocator]
static A: System = System;
# Profile Rust binary
cargo build --release
heaptrack ./target/release/myapp
# Note: debug symbols improve backtraces
cargo build --profile release-with-debug
heaptrack ./target/release-with-debug/myapp
For heaptrack_print output reference and GUI usage, see [references/heaptrack-analysis.md](references/heaptrack-analysis.md).
Related skills
- Use `skills/profilers/valgrind` for Memcheck (correctness) and massif (alternative heap profiler)
- Use `skills/profilers/linux-perf` for CPU profiling alongside memory profiling
- Use `skills/rust/rust-profiling` for Rust-specific allocation profiling approaches
- Use `skills/runtimes/sanitizers` — ASan LeakSanitizer for leak detection without profiling overhead
Read more
name: heaptrack description: heaptrack memory profiler skill for Linux. Use when tracking heap allocations, finding memory leaks, measuring peak heap usage, identifying allocation hotspots, or comparing allocation behaviour between runs. Activates on queries about heaptrack, heap profiling, memory allocation analysis, heaptrack_print, allocation hotspots, or memory leak detection with heaptrack.
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
# Ubuntu/Debian sudo apt-get install heaptrack heaptrack-gui # Fedora sudo dnf install heaptrack # Arch sudo pacman -S heaptrack # Build from source git clone https://github.com/KDE/heaptrack.git cmake -S heaptrack -B heaptrack-build -DCMAKE_BUILD_TYPE=Release cmake --build heaptrack-build -j$(nproc)
2. Basic usage
# Profile a program (generates heaptrack.<prog>.<pid>.zst) heaptrack ./myapp arg1 arg2 # Attach to running process heaptrack --pid 12345 # Analyse the trace file heaptrack_print heaptrack.myapp.12345.zst # GUI analysis (if heaptrack-gui installed) heaptrack_gui heaptrack.myapp.12345.zst
3. Build for better profiling
# Build with debug symbols (essential for readable backtraces) cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build build # Then profile heaptrack ./build/myapp
4. Interpreting heaptrack_print output
heaptrack_print heaptrack.myapp.*.zst 2>/dev/null
Key sections:
total runtime: 2.34s
calls to allocation functions: 145,234 (62,064/s)
temporary allocations: 89,123 (38,087/s)
peak heap memory consumption: 45.23MB
peak RSS (including heap): 78.45MB
total memory leaked: 2.34MB
# Top allocation hotspots (by peak memory)
hotspot 1: 12.34MB peak
myapp::cache::Cache::insert(...)
at src/cache.cpp:142
...
# Top leaked allocations
leak 1: 2.34MB leaked in 1,234 allocations
myapp::connection::Connection::new(...)
at src/connection.cpp:67| Metric | Meaning | |--------|---------| | `total memory leaked` | Memory allocated but never freed | | `peak heap consumption` | Maximum live heap at any point | | `temporary allocations` | Allocated and freed within one call stack | | `calls to allocation functions` | Total malloc/new/realloc calls |
5. Filtering and analysis options
# Show top N hotspots heaptrack_print -p 10 heaptrack.myapp.*.zst # top 10 hotspots # Show flamegraph data heaptrack_print -f heaptrack.myapp.*.zst > alloc.folded flamegraph.pl alloc.folded > alloc.svg # Show only leaked allocations heaptrack_print -l heaptrack.myapp.*.zst # Show allocations above threshold heaptrack_print --min-cost 1048576 heaptrack.myapp.*.zst # >1MB only # Short summary heaptrack_print -s heaptrack.myapp.*.zst
6. Comparing two runs
# Record baseline heaptrack ./myapp --config baseline.conf mv heaptrack.myapp.*.zst before.zst # Make changes, record again heaptrack ./myapp --config new.conf mv heaptrack.myapp.*.zst after.zst # Compare (shows diff of hotspots) heaptrack_print before.zst | head -20 > before.txt heaptrack_print after.zst | head -20 > after.txt diff before.txt after.txt
7. heaptrack vs Valgrind massif
| Feature | heaptrack | Valgrind massif | |---------|-----------|-----------------| | Overhead | ~2-3x | ~20x | | Output | Compressed trace + GUI | Text/ms_print | | Leak detection | Yes | Yes | | Peak tracking | Yes | Yes | | Temporal view | Yes (GUI) | Yes (ms_print) | | Platform | Linux only | Linux, macOS | | Needs recompile | No | No | | Call graph | Full stack traces | Full stack traces |
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:
// Rust: use system allocator so heaptrack can intercept use std::alloc::System; #[global_allocator] static A: System = System;
# Profile Rust binary cargo build --release heaptrack ./target/release/myapp # Note: debug symbols improve backtraces cargo build --profile release-with-debug heaptrack ./target/release-with-debug/myapp
For heaptrack_print output reference and GUI usage, see [references/heaptrack-analysis.md](references/heaptrack-analysis.md).
Related skills
- Use `skills/profilers/valgrind` for Memcheck (correctness) and massif (alternative heap profiler)
- Use `skills/profilers/linux-perf` for CPU profiling alongside memory profiling
- Use `skills/rust/rust-profiling` for Rust-specific allocation profiling approaches
- Use `skills/runtimes/sanitizers` — ASan LeakSanitizer for leak detection without profiling overhead
A curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.
Repo: mohitmishra786/low-level-dev-skills
Other skills on low-level-dev-skills.
- /custom-allocators
Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning jemalloc/mimalloc, writing Rust GlobalAlloc, or benchmarking allocator performance. Activates on queries about jemalloc, mimalloc, tcmalloc, arena allocator,
Open skill - /numa-programming
NUMA programming skill for multi-socket memory locality. Use when detecting NUMA topology, binding processes with numactl, using libnuma API, building NUMA-aware data structures, or measuring remote access penalties. Activates on queries about numactl, libnuma, NUMA topology,
Open skill - /af-xdp
AF_XDP skill for high-performance XDP sockets. Use when creating AF_XDP sockets, configuring UMEM and XSK rings, XDP_REDIRECT programs, copy vs zero-copy mode, or comparing with DPDK. Activates on queries about AF_XDP, xsk_umem, XDP_REDIRECT, libbpf xsk, or zero-copy XDP.
Open skill - /dpdk
DPDK skill for userspace packet I/O. Use when initializing EAL, configuring PMD drivers, using mbuf pools and rte_ring, setting up huge pages, RSS, or testpmd validation. Activates on queries about DPDK, EAL, rte_eth_rx_burst, hugepages, PMD, or testpmd.
Open skill - /io-uring
io_uring skill for Linux async I/O. Use when building high-performance servers with liburing, multi-shot operations, provided buffers, fixed files, zero-copy send, or tokio-uring. Activates on queries about io_uring, SQE/CQE, liburing, IORING_OP_PROVIDE_BUFFERS, or io_uring vs
Open skill - /adc-dac-baremetal
Bare-metal ADC and DAC skill. Use when configuring analog sampling, DMA-driven ADC, calibration, or DAC output on MCUs. Activates on queries about ADC bare-metal, sampling time, DMA ADC, or DAC channel setup.
Open skill

