How to test for memory leaks?

P

p1r0

Hi

I was wondering if any of you could recommend me a good tool for
testing for memry leaks under Windows and/or Linux

Thanks in advance

p1r0
 
P

Phlip

p1r0 said:
I was wondering if any of you could recommend me a good tool for
testing for memry leaks under Windows and/or Linux

Purify and Valgrind, respectively...
 
D

defendusa2

Some static code analyzers will check for potential memory leaks.

PC-Lint isn't very expensive (a few hundred bucks). Coverity is better
but is much more expensive. I think turning the Visual C++ compiler
warning level all the way up (to 4) will find some potential problems.
Other compilers might be able to detect potential memory leaks also.

Sysinternals.com has some tools that might help. I tracked down a
handle leak using their task manager replacement. Microsoft also has a
tool called umdh which I haven't used but I know others that have.

btw: The company I worked for evaluated Coverity. It ran for a day and
located a bunch of problems, one of which was a memory leak that one of
my coworkers had just spent a month (on and off) tracking down, not to
mention the customer, customer support, etc. I think that PC-Lint and
the other static code analyzers might have found it also.

The other thing is that there are ways to reduce the odds of a memory
leak occurring. I don't know if you do this or not, but using libraries
such as the stl, instead of rolling your own, using a string class
instead of char *, using object that autorelease your locks, handles,
close files, etc. for you and catching and handling exceptions will
help. If you are not doing these, then detecting memory leaks is like
patching the Titanic with a bandaid. It is better to prevent the
problem than patch the holes one by one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top