简体   繁体   English

opencv内存泄漏在equalizeHist中?

[英]opencv memory leak in equalizeHist?

I am running a process in ~20000 images. 我正在〜20000张图像中运行一个进程。 It was crashing every time at a different point, so I decided to debug it. 每次都在不同的位置崩溃,所以我决定对其进行调试。 After a few debugging I have realized about this: 经过几次调试后,我意识到了这一点:

在此处输入图片说明

在此处输入图片说明

I've just create a dummy function that equalizes an image and when it goes out of the scope it does not release all the memory. 我只是创建了一个虚拟函数来均衡图像,当它超出范围时,它不会释放所有内存。 I have tried with: equalizedImage.release() but same result. 我试过:equalizedImage.release()但结果相同。

Any idea about what to do or if I am not managing something correctly?? 关于该怎么办或我是否管理不正确的任何想法?

(using Opencv version 2.4.9) (使用Opencv 2.4.9版)

Thank you!! 谢谢!!

该文档没有指出src和dest可以是同一映像。

I hate not to be able to comment for this, but I want to note a few things. 我讨厌对此无法发表评论,但我想指出几件事。

1) Windows' Task Manager memory usage indicator cannot be fully trusted for this purpose. 1)为此,不能完全信任Windows的任务管理器内存使用情况指示器。 The Process is free to keep some memory reserved for future use. 该进程可以自由保留一些内存以备将来使用。

2) Please post the code that leaks so we can reproduce it properly. 2)请发布泄漏的代码,以便我们正确复制它。 Possibly with tools like Valgrind the leak can be detected. 可能使用Valgrind这样的工具可以检测到泄漏。 At least that is better than the Task Manager. 至少那比任务管理器更好。

3) Have you considered upgrading to the latest release of OpenCV to see if this behavior disappears? 3)您是否考虑过升级到最新版本的OpenCV,以查看此行为是否消失?

4) I highly doubt that this has something to do with your crashes. 4)我非常怀疑这与您的崩溃有关。

Your code is fine and should not cause any leak. 您的代码很好,不会造成任何泄漏。 The problem is somewhere else. 问题出在别的地方。 However, there is common problem when linking openCV wrongly with your program (for example linking with MT while your program is MD or another wrong configurations) that cause a problem in releasing cv::Mat. 但是,在错误地将openCV与程序链接时(例如在程序为MD或其他错误配置时与MT链接)时,存在一个常见问题,这会导致释放cv :: Mat问题。 This problem usually appears in the Debug mode and disappeared in the Release mode. 此问题通常在调试模式下出现,而在发布模式下消失。 so you may try to debug it in the debug mode. 因此您可以尝试在调试模式下对其进行调试。 This problem may prevent Mat from being freed correctly. 此问题可能会阻止Mat正确释放。

BTW, what is the memory usage you are getting after 1000 epochs? 顺便说一句,在1000个时代之后您获得的内存使用量是多少?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM