在 VC++ 调试会话(按 F5 调试运行)Output 窗口的Debug页便看到了预期的内存泄漏dump。该dump形式如下:
etected memory leaks!
Dumping objects ->
J:\C++STUDY\memoryleak\memoryleak.cpp(11) : {42} normal block at 0x00430080, 100 bytes long.
Data: <hello > 68 65 6C 6C 6F 00 CD CD CD CD CD CD CD CD CD CD
Object dump complete.
The thread 0xA7C has exited with code 1 (0x1).
The program 'J:\C++STUDY\memoryleak\Debug\memoryleak.exe' has exited with code 1 (0x1).
如果不加#define _CRTDBG_MAP_ALLOC这条语句,内存泄漏的输出如下:
Detected memory leaks!
Dumping objects ->
{42} normal block at 0x00430080, 100 bytes long.
Data: <hello > 68 65 6C 6C 6F 00 CD CD CD CD CD CD CD CD CD CD
Object dump complete.
The thread 0x3DC has exited with code 1 (0x1).
The program 'J:\C++STUDY\memoryleak\Debug\memoryleak.exe' has exited with code 1 (0x1).
根据这段输出信息,你无法知道在哪个源程序文件里发生了内存泄漏。
文章评论(0条评论)
登录后参与讨论