유지보수/WinDBG
메모리 릭 _CrtSetDbgFlag, / _CrtSetBreakAlloc
산과 나무
2017. 7. 19. 16:33
#include <crtdbg.h>
//기본값을 사용한다.
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
OUTPUT에 메모리릭이 아래와 같이 출력되었다고 하면..
Detected memory leaks!
Dumping objects ->
{80} normal block at 0x00647380, 796 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
The program '[22712] ConsoleApplication2.exe' has exited with code 0 (0x0).
여기서, {80}은 할당인덱스인데, 이 값을 아래 함수에 넘겨, 콜스택을 확인하면 간단하게 메모리 릭 위치를 찾을 수 있겠다.
_CrtSetBreakAlloc(80);