Skip to content

Bytehound - Memory Profiler for Linux Cheatsheet

Bytehound - Memory Profiler for Linux Cheatsheet

Bytehound is a memory profiler for Linux that tracks every allocation and deallocation in a program and presents the results in an unusually good web UI. Beyond finding leaks, it shows allocation churn over time, groups allocations by call stack, and lets you filter interactively — “show me allocations larger than 1MB that were never freed, from this module.” It is a Rust-based tool that works with any native program (C, C++, Rust) via LD_PRELOAD.

Installation

MethodHow
ReleaseDownload bytehound + libbytehound.so from GitHub Releases
From sourcecargo build --release in the repo
RequirementsLinux x86-64; program with symbols (-g)
Verify./bytehound --version

Profiling a Program

# Preload the profiler and run your program
LD_PRELOAD=./libbytehound.so ./my-program

# This produces memory-profiling_*.dat
VariablePurpose
LD_PRELOAD=./libbytehound.soInject the allocator hooks
MEMORY_PROFILER_OUTPUTOutput file path
MEMORY_PROFILER_LOG=warnLog level
MEMORY_PROFILER_CULL_TEMPORARY_ALLOCATIONSReduce noise from short-lived allocations
MEMORY_PROFILER_DISABLE_BY_DEFAULTStart paused, enable programmatically

Viewing Results

# Start the web UI on the captured data
./bytehound server memory-profiling_*.dat
# → open http://localhost:8080
ViewShows
GraphsMemory usage over time (live, leaked, allocated)
AllocationsEvery allocation with stack, size, lifetime
Flame graphAllocation volume attributed to call stacks
LeakedAllocations never freed
FilteringInteractive query builder

The Filtering Language

Bytehound’s strength is slicing the data:

FilterFinds
Only leakedAllocations alive at exit
Size rangee.g. > 1 MiB
LifetimeShort-lived (churn) vs long-lived
Backtrace containsAllocations from a specific function/module
Time rangeAllocations during a window
# Conceptual: leaked allocations over 1MB from the parser module
leaked AND size > 1048576 AND backtrace contains "parser::"

What to Look For

SymptomInvestigate
RSS grows without bound”Leaked” view — allocations never freed
High CPU in the allocatorTemporary-allocation churn
Memory spike at a momentTime-range filter around the spike
One function dominatesAllocation flame graph
FragmentationMany small long-lived allocations

Scripting the Analysis

Bytehound exposes an API and CLI for automation:

CommandPurpose
bytehound server DATAInteractive UI
bytehound export-heaptrack DATAConvert for heaptrack tooling
REST APIQuery allocations programmatically
ScriptingCustom analyses over the dataset

Reducing Overhead

SettingEffect
Cull temporary allocationsMuch smaller output, less noise
Disable by default + enable in codeProfile only the interesting phase
Shorter runsData files grow quickly

Bytehound vs Other Memory Profilers

AspectBytehoundheaptrackValgrind massifjemalloc prof
OverheadLowLowVery highVery low
UIRich web UIQt GUIText/visualizerText + tooling
FilteringExcellentGoodLimitedLimited
SetupLD_PRELOADheaptrack ./progvalgrind --tool=massifAllocator config
Best forInteractive explorationFast heap profilingDeep correctnessProduction sampling

Compare with heaptrack for a similar low-overhead approach with a Qt UI; both beat Valgrind for realistic workloads.

Resources