Detect Memory Bugs With valgrind

Run a program under Memcheck to find leaks and invalid memory accesses.

LinuxdevelopercliDiagnosticsLow risk
Run valgrind --leak-check=full ./program to get a leak and error report.

01Command

Command
$ valgrind --leak-check=full ./my-program

02What it does

Valgrind emulates the CPU and tracks every memory operation, so use-after-free, uninitialized reads and leaks are reported with stack traces. It is irreplaceable for native debugging and only makes sense as a command-line workflow.

03Risk

RiskLow risk
Requirementssudo apt install valgrind
!Warning: Emulation slows execution by an order of magnitude and needs debug symbols for useful line numbers.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-10-13 · Category: Developer

06Related solutions