What do people here use when they think they have a memory leak? Any useful tools in VC++ that do anything useful?
Thanks
HD
Printable View
What do people here use when they think they have a memory leak? Any useful tools in VC++ that do anything useful?
Thanks
HD
I have found this to be helpful:
It will dump leaks to the debug windowPHP Code:#include <crtdbg.h>
#define CONSTRUCTOR_TRACE
#define FUNCTION_TRACE
#ifdef _DEBUG
#define DBG_NEW new(_NORMAL_BLOCK,__FILE__, __LINE__)
#endif
//Put in your main
//Setup Debug In .cpp
#ifndef NDEBUG
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); // Get current flag
flag |= _CRTDBG_LEAK_CHECK_DF; // Turn on leak-checking bit
_CrtSetDbgFlag(flag); // Set flag to the new value
#endif
I go through my code another time and tighten up the loose ends... :)
Why don't you search in the MSDN library on your PC?Quote:
Originally posted by HairyDave
What do people here use when they think they have a memory leak? Any useful tools in VC++ that do anything useful?
Thanks
HD
Put these code before other include headers
You need to have these too, but usually MFC wizard will put there for you, unless you handcoded the cpp yourself.Code:#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
And put this in the destructor of your classCode:#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
Compile your app in debug mode and do debug->GoCode:_CrtDumpMemoryLeaks();
If you want to know more in detail, search in the MSDN.:)