목차
DetectMemoryLeaks.h 396바이트
main.cpp 601바이트
Task10(메모리릭).sln 905바이트
Task10(메모리릭).vcproj 3.72KB
main.cpp 601바이트
Task10(메모리릭).sln 905바이트
Task10(메모리릭).vcproj 3.72KB
본문내용
#include
using namespace std;
//================================================================================//
// ※ 메모리릭 탐지(CRTDBG)
// - 프로그래머의 실수로 메모리 생성후 해제를 하지 않아 누수가 발생한다.
// crt를 이용해 어느정도 체크할수 있다.
// - 사용헤더 : crtdbg.h
// - 학습내용 : crtdbg를 이용해 메모리 누수난 곳을 찾아가 보도록 하자.
//================================================================================//
#include "DetectMemoryLeaks.h"
int main(void)
{
int bb =0;
int* aa = new int[100];
system("PAUSE");
return 0;
}
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
#pragma once
#ifdef _DEBUG
#define CRTDBG_MAP_ALLOC
#include
#include
#define new new(_CLIENT_BLOCK, __FILE__, __LINE__)
class DetectMemoryLeaks
{
public:
DetectMemoryLeaks() { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF|_CRTDBG_DELAY_FREE_MEM_DF); }
~DetectMemoryLeaks() { _ASSERTE( _CrtCheckMemory() ); }
} _DetectMemoryLeaks;
#endif
using namespace std;
//================================================================================//
// ※ 메모리릭 탐지(CRTDBG)
// - 프로그래머의 실수로 메모리 생성후 해제를 하지 않아 누수가 발생한다.
// crt를 이용해 어느정도 체크할수 있다.
// - 사용헤더 : crtdbg.h
// - 학습내용 : crtdbg를 이용해 메모리 누수난 곳을 찾아가 보도록 하자.
//================================================================================//
#include "DetectMemoryLeaks.h"
int main(void)
{
int bb =0;
int* aa = new int[100];
system("PAUSE");
return 0;
}
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
#pragma once
#ifdef _DEBUG
#define CRTDBG_MAP_ALLOC
#include
#include
#define new new(_CLIENT_BLOCK, __FILE__, __LINE__)
class DetectMemoryLeaks
{
public:
DetectMemoryLeaks() { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF|_CRTDBG_DELAY_FREE_MEM_DF); }
~DetectMemoryLeaks() { _ASSERTE( _CrtCheckMemory() ); }
} _DetectMemoryLeaks;
#endif
소개글