Valgrind and Sanitizers

Valgrind runs your binary in a virtual CPU, tracking every byte’s allocation status. Memcheck (default tool) catches: use of uninitialized values, reads/writes past allocated blocks, memory leaks, double frees, mismatched alloc/dealloc. ~20x performance overhead. AddressSanitizer (ASan, -fsanitize=address) is a compiler instrumentation approach — faster (~2x overhead) but requires recompilation. ThreadSanitizer (TSan, -fsanitize=thread) catches data races in m09-concurrency. These tools are non-negotiable for serious C development.

Appears In

m03-dynamic-memory