News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Reports a memory leak

Started by tumanovalex, November 17, 2022, 02:39:06 PM

Previous topic - Next topic

tumanovalex

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 leakDetected 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.