In program debugging mode:
#include <malloc.h>
#include <crtdbg.h>
#include <iostream>
int main()
{
int tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
tmpDbgFlag |= _CRTDBG_DELAY_FREE_MEM_DF;
tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF;
tmpDbgFlag |= _CRTDBG_DELAY_FREE_MEM_DF;
_CrtSetDbgFlag(tmpDbgFlag);
int* p = NULL, N = 3;
p = (int*)malloc(sizeof(int) * N);
// free(p);
return 0;
}
Visual Studio information about memory leak
Detected memory leaks!
Dumping objects ->
{159} normal block at 0x000001A602D37C50, 12 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD
Code Blocks only reports that "D:\MyProgramming\cbBookExamles\main.cpp|12|warning: variable 'p' set but not used [-Wunused-but-set-variable]|"
Please tell me how to configure CodeBlocks so that it reports memory leaks.