valgrind

Detect memory errors and leaks in native binaries with Valgrind Memcheck.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/awfixers-stuff/opencode-config --skill valgrind-awfixers-stuff
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: valgrind
Source: https://github.com/awfixers-stuff/opencode-config/tree/main/skills/valgrind
Command: npx skills add https://github.com/awfixers-stuff/opencode-config --skill valgrind-awfixers-stuff

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

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.

Frequently Asked Questions about valgrind

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find memory leaks and use-after-free errors in a C++ binary I cannot recompile?▼

Run Memcheck on the native binary to detect use-after-free, invalid reads, and leaks. It requires a native executable and optionally debug symbols, providing detailed reports without recompilation or sanitizers.

What is the best way to profile CPU cache misses in a native program?▼

Use Cachegrind to simulate CPU cache behavior and generate function-level profiling data. It helps compare cache miss rates before and after hot-path optimizations to guide performance tuning.

Can I track heap memory growth over time with Valgrind?▼

Yes, Massif profiles heap usage over time to locate peak allocations and gradual memory growth. It takes snapshots of heap memory to help identify where and when memory consumption increases.

Does Valgrind work with C/C++ programs when sanitizers are unavailable?▼

Yes, Valgrind works with native C/C++ binaries when sanitizers are unavailable or impractical. It instruments the executable at runtime, requiring no recompilation, to detect memory errors and profile performance.

How do I suppress memory errors from third-party libraries in Valgrind reports?▼

Use suppression files to filter known noise from third-party libraries in Memcheck reports. Run the executable with flags for leak checking and origin tracking, saving output logs for analysis.

When should I not use Valgrind for memory profiling?▼

Avoid Valgrind when low overhead is critical, as runtime instrumentation slows execution significantly. Prefer compiler sanitizers for faster checks during development, and reserve Valgrind for unmodifiable binaries.