我已经得到了下面的代码,我认为它基于Finding Memory Leaks Using the CRT Library,应该打印出内存泄漏的行号。CRT不打印内存泄漏的行号
#include "stdafx.h"
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <iostream>
void derp()
{
int* q = new int;
}
int main()
{
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
derp();
return 0;
}
当我运行它,我得到如下:
Detected memory leaks!
Dumping objects ->
{75} normal block at 0x0067E930, 4 bytes long.
Data: < > CD CD CD CD
Object dump complete.
基于微软的文档,我希望看到一个打印出在哪里泄漏的内存被分配的路线,但我不。
我做错了什么?我正在使用VS2015。
查看https://stackoverflow.com/q/3202520/4009370 –