|
-
Apr 2nd, 2001, 01:51 AM
#1
Thread Starter
Addicted Member
Good day, everybody...
I was wondering... how do I trace my program's memory leak, which is written in Visual C++? In other words, it's there any tool that is available for me to used to trace memory leakage?
Thank you...
-
Apr 2nd, 2001, 05:29 AM
#2
Monday Morning Lunatic
If you run it in the debugger, when your program finishes it makes a list of all memory leaks.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 2nd, 2001, 09:06 PM
#3
Thread Starter
Addicted Member
Thanks parksie...
Yeah, I discover this when i'm running in debug mode...
The problem is it doesn't really pin-point the place/statement that the leak happen...
I know I can sometimes trace back the pointers that I didn't deallocate.... but when a pointer is NULL, I can't really know which pointer is causing the leak...
-
Apr 3rd, 2001, 08:59 AM
#4
Monday Morning Lunatic
What I've done before is to, whenever I use new, to output using cerr the location of the memory area, and the location of the pointer variable, like so:
Code:
int *pPtr = new int[50];
cerr << "Allocated " << (long)(&pPtr) << " pointing to " << (long)pPtr << " at " << __FILE__ << ":" << __LINE__ << endl;
Not sure if that's totally correct, but you get the idea
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|