使用_crtBreakAlloc查找内存泄漏-标识符"_crtBreakAlloc"身份不明 [英] Using _crtBreakAlloc to find memory leaks - identifier "_crtBreakAlloc" is unidentified

查看:87
本文介绍了使用_crtBreakAlloc查找内存泄漏-标识符"_crtBreakAlloc"身份不明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图按照此建议在监视"窗口中使用_crtBreakAlloc 链接,但是值行显示标识符"_crtBreakAlloc"未识别,并且根本无法正常工作.

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.

我做错了什么?顺便说一下,我在使用Visual Studio.

What am I doing wrong? I'm using Visual Studio by the way.

代码示例:

#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;
}

然后我将_crtBreakAlloc写入监视"窗口的名称"字段中,并在遇到断点时按Enter键.

I then write _crtBreakAlloc into the Name field of the Watch window and hit enter when encountering the breakpoint.

推荐答案

_crtBreakAlloc是VS2015下的一个宏,该宏被调用返回int的指针的函数所代替.在监视窗口中跟踪变量似乎不是一种选择.
最好在您的(调试)代码中插入如下内容:

_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;

这篇关于使用_crtBreakAlloc查找内存泄漏-标识符"_crtBreakAlloc"身份不明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆