Running valgrind, I get a lot of memory leaks in opencv, especially with the namedWindow function.
Basically I have a CSImg and PGImg image:
std::string cs = "Computer Science Students"; std::string pg = "Politics and Government Students"; CSImg.displayImage(cs); cv::destroyWindow(cs); PGImg.displayImage(pg); cv::destroyWindow(pg);
Image Display Function:
void ImageHandler::displayImage(std::string& windowname){ namedWindow(windowname); imshow(windowname, m_image); waitKey(7000); }
Valgrind gives me huge memory leaks when I display Image. For instance:
==6561== 2,359,544 bytes in 1 blocks are possibly lost in loss record 3,421 of 3,421 ==6561== at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6561== by 0x4F6C94C: cv::fastMalloc(unsigned long) (in /usr/lib/libopencv_core.so.2.3.1) ==6561== by 0x4F53650: cvCreateData (in /usr/lib/libopencv_core.so.2.3.1) ==6561== by 0x4F540F0: cvCreateMat (in /usr/lib/libopencv_core.so.2.3.1) ==6561== by 0x56435AF: cvImageWidgetSetImage(_CvImageWidget*, void const*) (in /usr/lib/libopencv_highgui.so.2.3.1) ==6561== by 0x5644C14: cvShowImage (in /usr/lib/libopencv_highgui.so.2.3.1) ==6561== by 0x5642AF7: cv::imshow(std::string const&, cv::_InputArray const&) (in /usr/lib/libopencv_highgui.so.2.3.1) ==6561== by 0x40CED7: ImageHandler::displayImage(std::string&) (imagehandler.cpp:33) ==6561== by 0x408CF5: main (randomU.cpp:601)
imagehandler.cpp line 33:
imshow(windowname, m_image);
randomU.cpp line 601:
CSImg.displayImage(cs);
Any help is appreciated. Ask for additional information that you need.
source share