Valgrind pros and cons : a quick summary

Valgrind pros:

  • Catches common memory bugs (UB) on dynamically allocated memory regions
    • Using uninitialized variables
    • Out-of-bounds memory accesses (read/write underflow/overflow bugs)
    • Use-after-free / use-after-return (out-of-scope) bugs
    • Double free
    • Leakage
  • No modification to source code required
  • No recompile required
  • No special compiler flags required

Valgrind cons:

  • Performance: target software may run up to 10 to 30 times slower when run under Valgrind.
  • Memory footprint: each allocation within the target program requires Valgrind to make a memory allocation as well (making running Valgrind on highly-resource-constrained embedded Linux systems difficult).
  • Cannot catch bugs on statically (compile-time) ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.