Author Topic: Reports a memory leak  (Read 2081 times)

Offline tumanovalex

  • Multiple posting newcomer
  • *
  • Posts: 23
Reports a memory leak
« on: November 17, 2022, 02:39:06 pm »
In program debugging mode:
Code
#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
Code
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.