User forums > Using Code::Blocks

Reports a memory leak

(1/1)

tumanovalex:
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;
}
--- End code ---
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

--- End code ---
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.

Navigation

[0] Message Index

Go to full version