#include <iostream>
#include <memory>
#define USE_CRTDB 0
#if USE_CRTDB
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
void EnableMemLeakCheck()
{
int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
_CrtSetDbgFlag(tmpFlag);
}
#else
#include <vld.h>
#endif
int memoryLeakTest()
{
char *sss = new char[300];
char* ddd = "nihao.kkk";
memcpy(sss, ddd, strlen(ddd) + 1);
return 0;
}
int mainmemoryLeakTest()
{
#if USE_CRTDB
EnableMemLeakCheck();
//_CrtSetBreakAlloc(1463);
#endif
std::cout << "test start !!!\n";
for (int i = 0; i < 10; i++)
{
memoryLeakTest();
std::cout << "memory leak test: " << i << "\n";
}
std::cout << "test end !!!\n";
system("pause");
return 0;
}