I agree with bmargulies - Valgrind is absolutely the best tool for automatically detecting improper memory usage. Almost all Linux distributions should have it, so just emerge valgrind or apt-get install valgrind or whatever your distribution uses.
However, Valgrind is hardly the least cryptic thing, and it usually helps you determine when the program ultimately turned to memory incorrectly - if you saved the wrong array index in a variable and then accessed it later, then you still have to figure it out. However, especially when combined with a powerful debugger such as GDB (the backtrace or bt command is your friend), Valgrind is an incredibly useful tool.
Remember to compile the -g flag (if you are using GCC, at least), or Valgrind and GDB will not be able to tell you where a memory error occurred in the source.
source share