Remember a long time ago, when I used Purify to find lots of errors with SANE? Now a similar tool is available for all. Check out valgrind, <URL:http://developer.kde.org/~sewardj/>.
> Valgrind, an open-source memory debugger for x86-GNU/Linux > > Valgrind is a GPL'd tool to help you find memory-management problems > in your programs. When a program is run under Valgrind's supervision, > all reads and writes of memory are checked, and calls to > malloc/new/free/delete are intercepted. As a result, Valgrind can > detect problems such as: > > - Use of uninitialised memory > - Reading/writing memory after it has been free'd > - Reading/writing off the end of malloc'd blocks > - Reading/writing inappropriate areas on the stack > - Memory leaks -- where pointers to malloc'd blocks are lost forever > - Passing of uninitialised and/or unaddressible memory to system calls > - Mismatched use of malloc/new/new [] vs free/delete/delete [] > > Valgrind tracks each byte of memory in the original program with nine > status bits, one of which tracks addressibility of that byte, while > the other eight track the validity of the byte. As a result, it can > detect the use of single uninitialised bits, and does not report > spurious errors on bitfield operations. It only works on linux/x86, but on that platform works just fine. :-)