09 September 2010

Memory leaks gone away!

I debugged all day and finally figured out what went wrong with my codes and now no memory leaks possessed by my cute little program! Thanks to valgrind and the following blog:

http://www.linuxprogrammingblog.com/using-valgrind-to-debug-memory-leaks

That blog helped me rethink about the usage and meaning of valgrind message. There were two memory leaks in my program, and both of them were obvious ones. If valgrind complains about obvious memory leaks ('definitely lost' category), then your program must have obvious memory leaks! Indeed, I just found how stupid I was not being able to spot those mistakes immediately!

Be cautious when you allocating heap memory with conditional branches in your codes. That is really a common mistakes.

Now I can move forward.

No comments: