不知道在哪里看到的,关于内存泄露的检测,在此处记下。
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#ifdef _DEBUG
#define DEBUG_CLIENTBLOCK new(_CLIENT_BLOCK, __FILE__, __LINE__)
#else
#define DEBUG_CLIENTBLOCK
#endif
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#ifdef _DEBUG
#define new DEBUG_CLIENTBLOCK
#endif
void _exit_()
{
int i = _CrtDumpMemoryLeaks();
assert( i == 0 );
}
int main( void )
{
atexit( _exit_ );
int *p = new int;
return 0;
}