我正在为 Windows 商店开发 3D 游戏。我在游戏中检测到内存泄漏,但在调试时我无法在输出中看到内存泄漏的文件名和行号。以下是我包含的用于检测内存泄漏的代码行:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
_CrtDumpMemoryLeaks();
以下是调试应用程序的输出:
Detected memory leaks!
Dumping objects ->
{1686} normal block at 0x06FD72E8, 8 bytes long.
Data: < > 08 F5 FE 03 00 00 00 00
{1685} normal block at 0x03FEF500, 40 bytes long.
Data: < x r > 20 E5 B4 01 78 EE FE 03 E8 72 FD 06 00 A9 03 04
{1684} normal block at 0x0403A900, 64 bytes long.
Data: <W i n d o w s . > 57 00 69 00 6E 00 64 00 6F 00 77 00 73 00 2E 00
{1676} normal block at 0x0406C858, 36 bytes long.
Data: < K > FF FF 00 00 FF EE 82 EE FF 4B 00 82 FF 00 00 FF
{1658} normal block at 0x06FD7208, 8 bytes long.
Data: < > 80 EE FE 03 00 00 00 00
{1657} normal block at 0x03FEEE78, 40 bytes long.
Data: < r J > 00 F5 FE 03 F8 F3 FE 03 08 72 FD 06 E0 4A F7 06
然而,根据 Microsoft 博客,当_CRTDBG_MAP_ALLOC包含在如下代码中时,我应该得到文件的名称和行号:
Detected memory leaks!
Dumping objects ->
C:\PROGRAM FILES\VISUAL STUDIO\MyProjects\leaktest\leaktest.cpp(20) : {18}
normal block at 0x00780E80, 64 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
即使在代码中包含_CRTDBG_MAP_ALLOC后,我也没有得到类似的输出(文件名和行号)。请帮我解决这个问题。
提前致谢!