My Vis C++ program takes forever to exit. Reason: it is dumping potential
memory leaks. I like finding leaks once a month, but not every time I run.
How do I turn mem leak dumping off?
I looked in help, and it said leak dumping is enabled with #define
CRTDBG_MAP_ALLOC ... but I do not have that #define anywhere in my code.
I _do_ have the /RTC1 (same as both /RTCs and /RTCu ) but the help for those
says nothing about memory leaks; and Id like to leave /RTC1 on all the time.
Thanks in advance for any help,
neal
> My Vis C++ program takes forever to exit. Reason: it is dumping potential
> memory leaks. I like finding leaks once a month, but not every time I run.
> How do I turn mem leak dumping off?
>
> I looked in help, and it said leak dumping is enabled with #define
> CRTDBG_MAP_ALLOC ... but I do not have that #define anywhere in my code.
In non-MFC applications, you can use _CrtSetDbgFlag function.
(Since the leaks are dumped, it is possible that this function is already used somewhere
in the application)
In MFC applications, you can use AfxEnableMemoryTracking function.
Regards,
Oleg
[VC++ MVP]
Martin Richter [MVP] - 06 May 2005 15:03 GMT
Hallo Oleg!
> In non-MFC applications, you can use _CrtSetDbgFlag function.
> (Since the leaks are dumped, it is possible that this function is already used somewhere
> in the application)
>
> In MFC applications, you can use AfxEnableMemoryTracking function.
The MFC version finally calls _CrtSetDbgFlag too!

Signature
Martin Richter [MVP] WWJD
"In C we had to code our own bugs. In C++ we can inherit them."
FAQ : http://www.mpdvc.de
Samples: http://www.codeguru.com http://www.codeproject.com
Oleg Starodumov - 06 May 2005 15:30 GMT
Hello Martin,
> > In non-MFC applications, you can use _CrtSetDbgFlag function.
> > (Since the leaks are dumped, it is possible that this function is already used somewhere
[quoted text clipped - 3 lines]
>
> The MFC version finally calls _CrtSetDbgFlag too!
Yes, it does.
Calling AfxEnableMemoryTracking(FALSE) is just a bit simpler and less error prone
(e.g. because it is natural to use _CrtSetDbgFlag to clear _CRTDBG_LEAK_CHECK_DF
flag and expect it to suppress the leak report, but in case of MFC it will not work.
Instead _CRTDBG_ALLOC_MEM_DF should be cleared, and that's what
AfxEnableMemoryTracking does)
Oleg