#include <stdio.h>
#include <stdlib.h>
#include <crtdbg.h>
/************************************************************************/
/* 实现代码在dbgheap.c */
/************************************************************************//
#define CHECK_MEM
void f()
{
int *p=new int[10];
}
int main()
{
f();
_CrtDumpMemoryLeaks();
system("pause");
}
F5执行
在输出窗口显示:
Detected memory leaks!
Dumping objects ->
{59} normal block at 0x003B5F78, 40 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.