What problem does it solve?
Valgrind helps diagnose hard-to-find memory errors and observe heap and cache behavior in native binaries when compilers or sanitizers are unavailable or insufficient. It surfaces invalid reads/writes, use-after-free, uninitialised reads, and detailed leak reports, and it provides cache simulation, call-graph profiling, and heap usage timelines to guide fixes and performance tuning.
Core Features & Use Cases
- Memcheck: detailed detection of invalid memory accesses, uninitialised reads, and leak classifications with options for full leak checking and origin tracking.
- Cachegrind & Callgrind: simulate CPU cache behavior and generate call graphs for function-level profiling and visualization with tools like KCachegrind.
- Massif: heap profiling over time to locate peak allocations and gradual memory growth.
- Use Case: run Memcheck on a production-style binary you cannot recompile to locate a use-after-free and generate a suppression for third-party library noise, or run Cachegrind to compare cache miss rates before and after a hot-path optimization.
Quick Start
Run Memcheck on a debug-built binary with full leak checking and origin tracking and save the report to a log file for analysis.