Detect Memory Bugs With valgrind
Run a program under Memcheck to find leaks and invalid memory accesses.
Run valgrind --leak-check=full ./program to get a leak and error report.
01Command
Command
$ valgrind --leak-check=full ./my-program02What 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
!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
- valgrind.1.en.html manual page (Debian bookworm)Evidence: Documents valgrind and the memcheck tool.
Last verified: 2026-10-13 · Category: Developer
06Related solutions
Inspect HTTP response headers with curl
Send a HEAD request to any URL and print the status line, server, content type, caching, and redirect headers.
Search text recursively in a directory with grep
Find every occurrence of a pattern across all files in a tree, printed as file:line:number matches.
Create an SSH key pair with ssh-keygen (Ed25519)
Generate a modern Ed25519 public/private key pair in ~/.ssh for authenticating to servers and Git platforms without passwords.