Debug Error: HEAP CORRUPTION DELETE
来源:互联网 发布:数据分析职业发展 编辑:程序博客网 时间:2024/04/29 20:30
今天debug程序,delete的时候出现了HEAP CORRUPTION DELETE 的错误。如下所示:
代码大体流程如下:
int *p = NULL;
p = new int [n]; // n 已知
if(p == NULL)
{
return -1;
}
function (p,n); //该函数会对p指向的值进行赋值
if(p != NULL)
{
delete [] p;
p = NULL;
}
在语句“delete [] p;”时出错。
百度了一下这个问题,都说HEAP CORRUPTION DELETE 是内存泄露的问题。多发生在delete时。于是各种检测代码,发现应该是申请了足够多的内存,n 足够大,在function()里面,对指针p没有索引大于 n-1的操作。在function()调用前后指针的首地址也没有发生变化。
同时,也发现其他人出现这个问题,大多显示的是:
heap corruption detected: after normal block(#xxx) at 0x xxxxxxxx
crt detected that the application wrote to menoryafter end of heap buffer;
而我出现的问题则是:
heap corruption detected: before normal block(#xxx) at 0x xxxxxxxx
crt detected that the application wrote to menory before start of heap buffer;
是不是问题出现在这段内存的前面呢?经过调试发现,中间调用的函数function()里出现了类似p[-1] = ?这样的操作。于是,成功修改通过。
- Debug Error: HEAP CORRUPTION DELETE
- C++ delete[] heap corruption
- heap corruption error
- Heap corruption detected error
- Heap corruption decected error
- Heap corruption detected error
- Heap Corruption Detected Error
- Heap corruption detected error
- Heap corruption detected error
- Error: HEAP CORRUPTION DETECTED
- Debug Error HEAD CORRUPTION DETECTED
- Heap Corruption
- heap corruption
- Heap Corruption
- Heap corruption
- Heap corruption
- Heap Corruption
- vc下debug和对heap corruption的处理
- Python使用easy install安装BeautifulSoup
- java面试常问的问题,欢迎补充
- Maven 仓库含义
- ocp学习随记(九)
- 基于C#弹幕类射击游戏的实现——(十)整合
- Debug Error: HEAP CORRUPTION DELETE
- Eclipse 各个版本命名
- sqlite3 常用操作
- eclipse使用androVM虚拟机心得
- 借书方案
- UVA10670-Work Reduction
- Android版本介绍
- eclipse快捷键帮助
- C++面向对象析构函数用法,destructor