As long as your program is small and single threaded its easy to debug the memory leaks and corruptions, but when the programs grows bigger and bigger...we now have a problem of finding missing memory allocations and stack corruptions. There are tools to find these and one of them is valgrind which I found it to be easy to use and efficient.