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...
Printable View
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...
If you run it in the debugger, when your program finishes it makes a list of all memory leaks.
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...
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:
Not sure if that's totally correct, but you get the idea :)Code:int *pPtr = new int[50];
cerr << "Allocated " << (long)(&pPtr) << " pointing to " << (long)pPtr << " at " << __FILE__ << ":" << __LINE__ << endl;