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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wierd Memory Leaks !!

Status
Not open for further replies.

nawaf

Programmer
Jun 11, 2001
12
0
0
KW
HeLLo Guys,
I'm having a bit of a problem here, I finsihed coding my program, it works corectly, but after finshing the debugging, MS VC++ 6.0 just gives me a message in the output pane :
etected memory leaks!
Dumping objects ->
{318897} normal block at 0x00AB4E00, 104 bytes long.
Data: < `N > 05 00 00 00 20 60 4E 00 0B 00 00 00 0A 00 00 00
{318887} normal block at 0x00AB3E40, 104 bytes long.
Data: < `N > 05 00 00 00 20 60 4E 00 0B 00 00 00 0A 00 00 00
{318886} normal block at 0x00AB3C20, 104 bytes long.
Data: < `N > 05 00 00 00 20 60 4E 00 0B 00 00 00 0A 00 00 00
{318881} normal block at 0x00AB30E0, 104 bytes long.
Data: < `N > 05 00 00 00 20 60 4E 00 0B 00 00 00 0A 00 00 00
....
....

strcore.cpp(118) : {2461} normal block at 0x00A91460, 34 bytes long.
Data: < S++/> 01 00 00 00 15 00 00 00 15 00 00 00 53 2B 2B 2F
strcore.cpp(118) : {2440}


but I'm sure I deleted every object I allocated dynamically, what is it, I don't find where the leak is, could anyone help me please ?
Thanks

 
Take care with the objects allocated dinamically in Constructors, Copy constructors or operators, also with the objects dealocated in destructors.

Some of these, may be called by the program in a masked way and you may have memory leaks.

Hope this helps,

s-)

Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
What got me one time was CException. If you are catching a CException, you must call the Delete() function of the exception. Check to see if you are catching any of these or any classes that inherit from this.

Matt
 
You can use smart pointers and autopointers instead of pointers. John Fill
1c.bmp


ivfmd@mail.md
 
HeLLo,
Mr. JohnFill , can you please clarify what do you mean by smart pointers and auto pointers?
Thanks
 
autopointers are pointers from STL. You use them like
#include<iostream>
#include<memory>
using namespace std;
int main()
{
auto_ptr<int> x;//quite the same as int* x
x=new int;
*x.get=100;
cout<<*x.get();
return 0;
}

The smart pointers are Microsoft specific templates from ATL, but are much more reliable. Is the same idea as in COM AddRef/Release John Fill
1c.bmp


ivfmd@mail.md
 
John, looks useful. Would there be a way to use auto or smart pointers using less verbose code then what I'm doing with regular code for dynamically allocated arrays. See thread116-107726 for details. If so, wanna give me a quick example?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top