Link to home
Start Free TrialLog in
Avatar of sneeuw
sneeuwFlag for Belgium

asked on

What's a good & easy way to check for memory leaks

Hi,

Using a standard installation of Borland cpp Builder 5.
(or another app I can download somewhere ?)
What's the best way to check an app for memory leaks ?

I mean ... I think I have no leaks but want to run the app a while, do some stuff etc. and check if all memory is freed always.

Is there a way ?

ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of curri
curri

There are tons of free and commercial ones. You may want to check freshmeat or do a search on your favorite search engine.

You may also want to check this (kinda outdated, dec/2000) article on slashdot about tools for checking memory leaks (slashdot is frequented more by the linux crowd, so most tools will be for linux/unix. There is all kind of people though.

http://www.slashdot.org/askslashdot/00/12/20/0438234.shtml

Orlando
I like to wrap new, delete, malloc, realloc, etc...  and pipe a delimeted output of ptr values, and sizes to a file for debugging.  You can then do a sort and a regular expression search to see if there is anything hanging out there that is not getting cleaned up properly.

There are also a few good debug classes out there that will provide some good info (and the output can help you sort out the memory stuff more quickly), but they require some extra work on your part to implement properly.  I have one that I like to use, but can't find a link to it anywhere.  If you want to look at it, post your e-mail and I will send it to you.
I can't help you on

https://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20156272

as I can't post to quesitons that Axter has posted to.

However he is not telling you a very important point that is likely to be the problem with your code.  (It IS the problem with the code he posted.)

dynamic_cast uses RTTI and RTTI is only guaranteed to work on a class that has at least one fivrtual function.  Do you have a virutal function defined in your base class?
The best way of finding a memory leak is by using a software called PURIFY from RATIONAL softwares. It gives u the details of all memory related information for a piece of code or a application.
So that is the answer then?  Nothing else posted would solve the problem?

NizamLapis13, please read the comment/answer guidelines.  You cannot post answer if other answers were already posted as comments.  
sneeuw,

These questions are still open and our records show you logged in recently. Please resolve them appropriately as soon as possible. Continued disregard of your open questions will result in the force/acceptance of a comment as an answer; other actions affecting your account may also be taken. I will revisit these questions in approximately seven (7) days. Please note that the recommended minimum for an "Easy" question is 50 points.
https://www.experts-exchange.com/jsp/qShow.jsp?ta=winprog&qid=20183446
https://www.experts-exchange.com/jsp/qShow.jsp?ta=winprog&qid=20158806
https://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20192985
https://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20151309
https://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20137274
https://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20136466
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20088277
https://www.experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=20183228

EXPERTS: Please leave your thoughts on this question here.

Thanks,

Netminder
Community Support Moderator
Experts Exchange
Force/accepted by

Netminder
Community Support Moderator
Experts Exchange