Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

How turn off memory leak dumping?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
noleander - 04 May 2005 18:16 GMT
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
Oleg Starodumov - 06 May 2005 11:20 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.