Reputation: 7759
Is there a way to suppress Valgrind's memcheck until a defined (signalled by me in any way) stable state has been reached; i.e. application startup is finished, and I only want to start tracking new allocations from now on. Either time based or using a Unix signal or similar mechanism.
Upvotes: 0
Views: 321
Reputation: 3807
memcheck must track all the allocated (and freed) memory: if it would only track memory from some point in time, then all accesses to the memory allocated before this time would be considered as accessing not allocated memory.
Now, depending on what you want to 'avoid seeing' before this stable state, there are things you can do.
If you do not want to see errors before the stable state, you can call VALGRIND_DISABLE_ERROR_REPORTING as soon as your application starts, and call VALGRIND_ENABLE_ERROR_REPORTING when the stable state is reached.
If what you want to see is have an idea on how much memory is allocated after this stable state, you can do a memory leak search when the stable state is reached to show the memory state. Afterwards, you can do a "delta leak search" that shows what has been allocated/freed since the previous leak search.
You can do that interactively from the shell, using vgdb, or use GDB+vgdb to put breakpoints in your program and do the above at precise places in your program.
See e.g. http://www.valgrind.org/docs/manual/manual-core-adv.html and http://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.monitor-commands for more information.
Upvotes: 1