VS2012 释放vector内存时候出错,不知道什么问题

linchaowen 2013-08-10 05:59:58
HEAP[MWO3.exe]: Invalid address specified to RtlValidateHeap( 00690000, 033216A0 )
MWO3.exe 已触发了一个断点。
Debug Assertion Failed!

Program: E:\opencv_vs2012\MyWrite\MyWriteOpencv3\Debug\MWO3.exe
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c
Line: 1322

Expression: _CrtIsValidHeapPointer(pUserData)

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
线程 0x1c48 已退出,返回值为 3 (0x3)。
线程 0x1d50 已退出,返回值为 3 (0x3)。
线程 0x1c78 已退出,返回值为 3 (0x3)。
线程 0x1ebc 已退出,返回值为 3 (0x3)。
线程 0x1f3c 已退出,返回值为 3 (0x3)。
线程 0x1d20 已退出,返回值为 3 (0x3)。
线程 0x141c 已退出,返回值为 3 (0x3)。
线程 0x1c58 已退出,返回值为 3 (0x3)。
线程 0x1164 已退出,返回值为 3 (0x3)。
程序“[6264] MWO3.exe”已退出,返回值为 3 (0x3)。

错误码,程序没错,在最后return的时候出错,似乎是释放内存的问题。
使用vector<Mat>().swap(projections);提前释放内存也是错的,找到具体条目,可惜无法放弃不用。。。
...全文
3021 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenqingzao 2015-09-22
  • 打赏
  • 举报
回复
for (int i = 1; i <=255; i++) { _itoa_s(i, temp_file, 4, 10); filename0 = temp_file; filename = _Imagespath + filename0 + ".jpg"; cout << "哇哈哈10" << endl; filename1 =Imagespath1 + filename0 + ".jpg"; cout << "哇哈哈11" << endl; Mat image_src = imread(filename); cout << "哇哈哈1" << endl; if (image_src.empty()) { cout << "could not load image" << endl; exit(0); } vector<Mat> bgr_src, bgr_dst; split(image_src, bgr_src);//分解每个通道 通道的拆分 cout << "哇哈哈2" << endl; for (int j = 0; j < 3; j++) { Mat I = getimage(bgr_src[j]); cout << "哇哈哈3" << endl; Mat p = I.clone(); cout << "哇哈哈4" << endl; Mat _q = guidedfilter(I, p, r, eps); cout << "哇哈哈5" << endl; Mat q = putimage(_q); cout << "哇哈哈6" << endl; bgr_dst.push_back(q); cout << "哇哈哈7" << endl; } merge(bgr_dst, frame); cout << "哇哈哈8" << endl; imwrite(filename1, frame); cout << "哇哈哈9" << endl; } } 大循环只执行了一次,就不执行了。也有那个错误。求指导,大家最后是怎么解决的啊
知行且执行 2014-03-09
  • 打赏
  • 举报
回复
这个是怎么解决的呢?
linchaowen 2013-08-11
  • 打赏
  • 举报
回复
恩啊,多谢了,我结贴了,先收点分回来。
真相重于对错 2013-08-10
  • 打赏
  • 举报
回复
用c++ 就要能准确把握你的程序所有的资源,而不是只在语言层面的了解他
linchaowen 2013-08-10
  • 打赏
  • 举报
回复
好吧,似乎是堆和栈的问题,似乎是因为数据太大,结果越界了。用new 把他存入堆就不会报错了,不过使用delete的时候似乎又出错了,不能释放= =。 话说程序结束会自动释放么?

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧