Valgrind does not require special compilation. You simply execute it like
so: valgrind --num-callers=15 progname. It will run the program
progname and intercept calls to malloc/free/new/delete and
monitor all memory uses.
Another useful flag is --gdb-attach=yes that invokes gdb on the
process when errors are detected, and let you debug the place of the
error.
Valgrind is good only for x86s running some non-ancient Linux - this
shouldn't be much of a problem.
Valgrind will report several types of errors:
Illegal read / illegal write errors.
Use of uninitialized values.
Illegal frees.
Inappropriate deallocation function.
Passing system call paramters with inadequate read/write permissions.
Valgrind will tell you, when possible, where in your code the relevant memory
blocks were allocated/freed.
Valgrind is most probably not installed on the Linux box you are working on,
however installation is trivial and fairly quick: download, unpack and then
run one after another: ./configure make make install
Valgrind's manual is available in the distribution directory under
docs/index.html.