gpt4 book ai didi

c++ - Valgrind OpenCV

转载 作者:行者123 更新时间:2023-12-01 14:50:39 24 4
gpt4 key购买 nike

这是我的测试程序:

#include "opencv2/videoio.hpp"

int main(int argc, char** argv) {
cv::VideoCapture videoCapture(argv[1]);
cv::Mat frame;
videoCapture.read(frame);
return 0;
}

我这样运行这个程序:

valgrind --leak-check=yes ./GyroRecord ./walks6/w63/39840012.avi > valgrind_output 2>&1

这样整个输出就保存在valgrind_output文件中。

可以检查 valgrind_output 的内容 here .

但是,如果链接在未来失效,这是总结:

==9677== LEAK SUMMARY:
==9677== definitely lost: 0 bytes in 0 blocks
==9677== indirectly lost: 0 bytes in 0 blocks
==9677== possibly lost: 1,352 bytes in 18 blocks
==9677== still reachable: 166,408 bytes in 1,296 blocks
==9677== of which reachable via heuristic:
==9677== newarray : 1,536 bytes in 16 blocks
==9677== suppressed: 0 bytes in 0 blocks
==9677== Reachable blocks (those to which a pointer was found) are not shown.
==9677== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==9677==
==9677== For counts of detected and suppressed errors, rerun with: -v
==9677== ERROR SUMMARY: 18 errors from 18 contexts (suppressed: 0 from 0)

我想将“可能丢失”的字节减少到 0。这可能吗?还是在使用 OpenCV 时我总是会有一些“可能丢失”的字节?

最佳答案

OpenCVvalgrind 提供了 suppression 文件(扩展名为 .supp),可用于隐藏有关已分配资源的消息(通常在程序执行的早期),这些消息将一直分配到程序结束并且操作系统必须清理困惑为止。

抑制文件放在/usr/share/OpenCV(在我的系统上):

例子:

valgrind --leak-check=yes --suppressions=/usr/share/OpenCV/valgrind.supp --suppressions=/usr/share/OpenCV/valgrind_3rdparty.supp ./GyroRecord ./walks6/w63/39840012.avi

OpenCV 项目上运行 valgrind 时,使用它们对我有很大帮助。

关于c++ - Valgrind OpenCV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42006343/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com