Saturday, January 24, 2009

Memory leak Detection tools

If you are a developer, you would know how important it is to make sure there are no memory leaks in your code. I tried a few tools to examine the leaks in the code. I have tried to group all the information in this post.

A memory leak tracking tool should be
-> Platform Independent and can be cross-compiled for different architectures
-> Should support multi-threaded environment
-> Can be statically or dynamically linked
-> Should be able to generate call stack or line number in the code
-> Should be able to detect double free, memory overwrite, buffer overrun and underrun errors

Valgrind is the most powerful for catching leaks in C/C++ however, it can't be cross-compiled on different architectures. Valgrind also has a inbuilt Heap-Profiler called Massif.
dmalloc is a very useful tool and satisfies all requirements on embedded systems and is supports mips architucture. dmalloc requires source recompilation which is an overhead.
Electric Fence effectively catches overwrites but could not even find even a single memory leak in my test code.
Google Perftools has a excellent heap-profiler. I have not used this framework extensively as it can't be cross-compiled for mips architecture.
Bounds Checker is a very good tool for development with Microsoft Visual Studio.

I did a bit of googling and found some very helpful links. Do visit Memory Leak Detection in Embedded Systems, Memory Checker comparison and my favorite Google-perftools


Anonymous said...

As a Newbie, I am always searching online for articles that can help me. Thank you

Anonymous said...

Rather cool site you've got here. Thanx for it. I like such topics and anything connected to them. I definitely want to read a bit more soon.