Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory Leaks Out of Control 2

Status
Not open for further replies.

Kalisto

Programmer
Feb 18, 2003
997
GB
Hi, In my code at present I have 500 memory leaks, which is not good (for my code, or my self esteem!)

I am doing a lot of work with one particular class, which is allocating memory, so I believe that this is where the issues are starting.

One of my class member variables is declared as

private:
char* pData;

in my destructor I have the line free ((char*) pData);

WHen this line is in my code it throws up the error Damage at Normal Block (#345). If I comment out the line then the code compiles normally, but I have this memory loss.

The data was allocated (in another function) using malloc or realloc, so I know that free() is the function to use, but what am I doing wrong.

MS memory leak detection is basic, is there a free 3rd party tool I can use to at least track down these leaks to a line / file in my code that is causing them ?

Regards,

K
 
Suggestion: look into replacing your regular pointers with smart pointers of some sort. Proper use of them should almost ensure you have no memory leaks.

has a smart pointer library you may find useful.
 
>chipperMDW
each of Microsoft STL, MFC and ATL have very good implementations of autopointers/smartpointers and memory/leak detecting functionalities.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
> each of Microsoft STL, MFC and ATL have very good implementations of autopointers/smartpointers and memory/leak detecting functionalities.

Ok.

I suggested Boost's smart pointers because there's a good chance they will become a part of the C++ Standard in the near future. Any good smart pointer library probably has similar capabilities.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top