在Windows上堆损坏,而不是Linux上的堆损坏
Heap corruption on Windows but not Linux
下面是一些简单的OpenCV代码,用于从视频文件创建帧并在帧上运行SURF特征检测器和提取器。当我在 Linux 和 OSX 上运行此代码时,它运行良好,但是在 Windows 上,我在两个注释行上收到堆损坏错误。
VideoCapture capture(vidFilename.c_str());
Mat frame;
capture >> frame;
SurfFeatureDetector *detector = new SurfFeatureDetector(minHessian);
vector<KeyPoint> frameKeypoints;
detector->detect(frame, frameKeypoints);
delete(detector); // Heap Corruption Detected
SurfDescriptorExtractor *extractor = new SurfDescriptorExtractor();
Mat frameDescriptors;
extractor->compute(frame, frameKeypoints, frameDescriptors);
delete(extractor); // Heap Corruption Detected
我不知道代码中可能导致这种情况的原因是什么。我正在使用VS 2010来编译代码,VS中是否有可能导致这种情况发生?
如上所述,您不会获得与堆损坏相关的任何异常并不意味着它没有发生。您的代码中会有问题,而不是在 VS 或编译器中。我之前关于类似文章的文章在这里也很有用。
https://stackoverflow.com/a/22074401/2724703
可能你也应该尝试在你的Linux上运行一些动态工具(Valgrind)。很有可能,你也会在使用Valgrind发现同样的错误。
这些动态工具将为您提供这些问题的根本原因。
相关文章:
- 在C++/Linux中设置单调时钟的一些技巧
- Linux的Cpp上的计时器
- 为什么会发生堆损坏
- 具有奇怪重复模板模式的派生类中的成员变量已损坏
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 在Linux中哪里可以找到互斥、未来等的源代码
- 如何在linux终端中同时编译和运行c++代码
- 在Linux for Windows上编译C++代码时出错
- 如何找到锁定Linux futex的C++行
- 在linux上调试巨大的C++项目
- 平均图像时图像损坏
- 如何针对特定情况调试和修复此双自由内存损坏问题
- 如何处理linux终端中带有负号(-)的C++中的命令行参数
- c++方法参数只能在linux的发布模式下自行更改
- 在Linux和C++中的Windows上,散列字符串值会产生不同的输出
- 为什么C中的通用链表中存储的数据已损坏
- 为什么此C 损坏的程序在Windows和Linux上的行为如此不同
- C++ Linux 中的双链表损坏
- 为什么Windows Visual Studio会损坏C样式字符串,而Linux不会?
- 在Windows上堆损坏,而不是Linux上的堆损坏