How turn off memory leak dumping?

G

Guest

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
 
O

Oleg Starodumov

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]
 
M

Martin Richter [MVP]

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!
 
O

Oleg Starodumov

Hello Martin,
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top