카테고리 없음

[C++] Checking memory leakage in C++

곽가누 2024. 11. 8. 19:04

use modules 

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
int main() {
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
    
    //test
    int* leak = new int[10];
    
   	return 0;
   }

If something appears like this, memory leakage exists. 

Else, it doesn't exists.