1)工程是MFC工程,或是工程的设置中有Use MFC in a Shared DLL,
2)很多地方说是要定义以下宏
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
但是我发现只要include <afx.h> 即可。(大家可以检测一下)
3)可以在F5运行程序后,在output窗口中看到如下的内存泄露的显示。(只在debug下有用哦)
4)如果有泄露,则显示如下:
Detected memory leaks!
Dumping objects ->
{214} normal block at 0x00D91618, 4 bytes long.
Data: < > 00 00 00 00
{208} normal block at 0x00D914D0, 4 bytes long.
Data: < > 00 00 00 00
{207} normal block at 0x00D91490, 4 bytes long.
Data: < > D0 14 D9 00
{205} normal block at 0x00D91410, 4 bytes long.
Data: < > 00 00 00 00
{204} normal block at 0x003AFFD8, 4 bytes long.
Data: < > 10 14 D9 00
{203} normal block at 0x003AFF98, 4 bytes long.
Data: < > 00 00 00 00
{202} normal block at 0x003AFF58, 4 bytes long.
Data: < : > 98 FF 3A 00
{200} normal block at 0x003AFF18, 4 bytes long.
Data: < > 00 00 00 00
Object dump complete.