MFC가 아닌 콘솔 프로그램에서는
1. define
1. define
// Leak
#if defined(_DEBUG)
# include <crtdbg.h>
# if defined(malloc)
# undef malloc
# endif
# define malloc(s) (_malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__ ))
# if defined(calloc)
# undef calloc
# endif
# define calloc(c, s) (_calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__ ))
# if defined(realloc)
# undef realloc
# endif
# define realloc(p, s) (_realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__ ))
# if defined(_expand)
# undef _expand
# endif
# define _expand(p, s) (_expand_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__ ))
# if defined(free)
# undef free
# endif
# define free(p) (_free_dbg(p, _NORMAL_BLOCK))
# if defined(_msize)
# undef _msize
# endif
# define _msize(p) (_msize_dbg(p, _NORMAL_BLOCK))
# define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
class CheckMemoryLeakForWin32 {
public:
CheckMemoryLeakForWin32() {
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
//_CrtSetBreakAlloc(956); // 중단점 트리거
}
~CheckMemoryLeakForWin32() {}
}CheckMemoryLeakForWin32;
#endif
'C++' 카테고리의 다른 글
strsafe.h (0) | 2012.03.24 |
---|---|
openssl + AES256 + Base64 (0) | 2012.03.11 |
UTF-8 변환 (UTF8Conv.h) (0) | 2012.03.10 |
#pragma message 를 활용한 할일 적어두기 (0) | 2012.03.07 |
오픈소스 라이센스 : libcurl, openSSL, wxWidgets (0) | 2012.02.26 |
Mutex로 중복실행 방지 (0) | 2012.02.24 |
[wxWidgets] command line 인자 받기 (0) | 2012.02.20 |
[libcurl] curl_multi_perform 사용시 -1 (select error) (0) | 2012.02.13 |