ckv
ckv

Reputation: 10830

Using AfxEnableMemoryTracking to detect Memory leaks

Has anybody personally used

AfxEnableMemoryTracking function provided by MFC

to detect memory leaks. How useful is it?

Upvotes: 4

Views: 1100

Answers (1)

Alex F
Alex F

Reputation: 43311

Memory tracking is enabled by default in MFC Debug builds. AfxEnableMemoryTracking is mostly used to temporary disable memory tracking in some code fragments, if it is necessary. To use MFC built-in memory leaks detection, ensure that every .cpp file contains the following code after all #include lines:

#ifdef _DEBUG
#define new DEBUG_NEW 
#endif

Upvotes: 4

Related Questions