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!

Memory Leak

Status
Not open for further replies.

danDD

Programmer
Sep 25, 1999
1
0
0
US
Visual C++ reports possible memory leak when a new app I wrote exits. How do<br>
I find the cause
 
Try debugging the application,<br>
and try to watch the dump that comes in the debug window, it will show you the leaks there,<br>
it will also give you the line number where the leak was<br>
in your code.<br>
For eg: to explain to you,<br>
I allocated memory for an array of CString objects<br>
pString = new CString[10]<br>
and did not free it,<br>
the dump it gave me in the debug window was.<br>
===========================================================<br>
Dumping objects -&gt;<br>
C:\Work\Mfc\CProjects\CloseTest\MainFrm.cpp(102) : {122} normal block at 0x00782590, 44 bytes long.<br>
Data: &lt; L_ L_ L_&gt; 0A 00 00 00 14 CB 4C 5F 14 CB 4C 5F 14 CB 4C 5F <br>
Object dump complete.<br>
===========================================================<br>
In this dump (102) is the line number of the statement which caused the leak and that is where I had allocated memory for the CString array.<br>
If you want to see the dump in a different application,<br>
there is a utility called Debug Print Viewer which u can <br>
download from <A HREF=" TARGET="_new"> which prints all the leaks of your program if any and also the output of the TRACE statements.<br>
Hope this helps.<br>
<br>
Sun
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top