We certainly do – it’s much easier to run valgrind against the unit tests than with the full program.
Also any memory errors are localised to the area of code the unit test is testing which makes it easier to fix.
Plus checking that you’ve fixed it is easier – because you’re running the unit test not a more complicated test against your full program.
If you’re running valgrind in an automated fashion you probably want --error-exitcode=<number> [default: 0]
Specifies an alternative exit code to return if Valgrind reported any
errors in the run. When set to the
default value (zero), the return value
from Valgrind will always be the
return value of the process being
simulated. When set to a nonzero
value, that value is returned instead,
if Valgrind detects any errors. This
is useful for using Valgrind as part
of an automated test suite, since it
makes it easy to detect test cases for
which Valgrind has reported errors,
just by inspecting return codes.
http://valgrind.org/docs/manual/manual-core.html#manual-core.erropts