|
-
Jan 3rd, 2003, 09:41 AM
#1
Thread Starter
Addicted Member
Memory Leaks
What do people here use when they think they have a memory leak? Any useful tools in VC++ that do anything useful?
Thanks
HD
-
Jan 3rd, 2003, 11:26 AM
#2
Frenzied Member
I have found this to be helpful:
PHP 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
It will dump leaks to the debug window
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Jan 5th, 2003, 05:31 AM
#3
Hyperactive Member
I go through my code another time and tighten up the loose ends...
-
Jan 5th, 2003, 06:33 AM
#4
Hyperactive Member
Re: Memory Leaks
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
Why don't you search in the MSDN library on your PC?
Put these code before other include headers
Code:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
You need to have these too, but usually MFC wizard will put there for you, unless you handcoded the cpp yourself.
Code:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
And put this in the destructor of your class
Code:
_CrtDumpMemoryLeaks();
Compile your app in debug mode and do debug->Go
If you want to know more in detail, search in the MSDN.
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
|