I am trying to use _crtBreakAlloc
in the Watch window as suggested in this link, but the value line says that 'identifier "_crtBreakAlloc" is unidentified' and it simply does not work.
What am I doing wrong? I'm using Visual Studio by the way.
An example of code:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <malloc.h>
int main()
{
int *arr = (int*)malloc(10 * sizeof(int)); //breakpoint here
free(arr);
return 0;
}
I then write _crtBreakAlloc into the Name field of the Watch window and hit enter when encountering the breakpoint.
_crtBreakAlloc
is a macro under VS2015 that is replaced by a call to a function returning a pointer to an int. Tracking a variable in the watch window doesn't seem an option.
Better insert in your (debug) code something like this:
_crtBreakAlloc = 18;