2025-03-14 21:59:59 -06:00
|
|
|
# valgrind
|
|
|
|
|
|
|
|
|
|
> Wrapper for a set of expert tools for profiling, optimizing and debugging programs.
|
|
|
|
|
> Commonly used tools include `memcheck`, `cachegrind`, `callgrind`, `massif`, `helgrind`, and `drd`.
|
2025-12-16 10:20:31 -07:00
|
|
|
> More information: <https://valgrind.org/docs/manual/manual-core.html#manual-core.options>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Use the (default) Memcheck tool to show a diagnostic of memory usage by `program`:
|
|
|
|
|
|
|
|
|
|
`valgrind {{program}}`
|
|
|
|
|
|
|
|
|
|
- Use Memcheck to report all possible memory leaks of `program` in full detail:
|
|
|
|
|
|
|
|
|
|
`valgrind --leak-check=full --show-leak-kinds=all {{program}}`
|
|
|
|
|
|
|
|
|
|
- Use the Cachegrind tool to profile and log CPU cache operations of `program`:
|
|
|
|
|
|
|
|
|
|
`valgrind --tool=cachegrind {{program}}`
|
|
|
|
|
|
|
|
|
|
- Use the Massif tool to profile and log heap memory and stack usage of `program`:
|
|
|
|
|
|
|
|
|
|
`valgrind --tool=massif --stacks=yes {{program}}`
|