zer0stimulus
zer0stimulus

Reputation: 23606

Valgrind: How to force it to generate heap summary without terminating process?

When using Valgrind, I noticed that it only generates the Heap Summary when the process is terminating. Is there a way to force Valgrind to scan the memory and print leak reports when process is still running?

Upvotes: 3

Views: 1348

Answers (2)

Employed Russian
Employed Russian

Reputation: 213375

In addition to the VALGRIND_DO_LEAK_CHECK client request, you can also run valgrind with --vgdb=yes to enable embedded gdbserver, and then issue monitor leak_check full reachable any command at the (gdb) prompt.

This doesn't require modifying and rebuilding the target program, and has other advantages: you can set breakpoints and perform leak checks at arbitrary points in the execution, not just the ones where you've put in the client request.

Upvotes: 9

TomH
TomH

Reputation: 9220

Use the VALGRIND_DO_LEAK_CHECK client request from valgrind/memcheck.h.

Upvotes: 4

Related Questions