#define _CRTDBG_MAP_ALLOC
#include<stdlib.h>
#include<crtdbg.h>
int main()
{
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
//int* p = (int*)malloc(10);
int * a = new int[10];
return 1;
}
试了下,对 malloc 支持很好,但对 new 就不行
用malloc 分配内存
可以看到具体什么文件,第几行
Detected memory leaks!
Dumping objects ->
d:\Test\dfg.cpp(11) : {49} normal block at 0x003932D8, 10 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD
Object dump complete.
用new分配内存
没法看到什么文件,第几行
Detected memory leaks!
Dumping objects ->
{49} normal block at 0x003932D8, 40 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
要如何设置,让 new 也可以详细输出呢?毕竟创建对象是用new