Memory leak in cv::viz::WImage3D::setImage() (Bug #3961)


Added by Jonathan Bouchard over 10 years ago. Updated over 10 years ago.


Status:Done Start date:2014-10-16
Priority:Normal Due date:
Assignee:Anatoly Baksheev % Done:

0%

Category:viz
Target version:-
Affected version:2.4.9 (latest release) Operating System:Linux
Difficulty: HW Platform:x64
Pull request:

Description

Repeatedly calling setImage on a WImage3D widget seems to take a copy of the image data each time. If this function is called in a loop, we get a memory leak.

The example code below replicates the problem on my machine. By the end of the loop, 3GB of memory is required by the application.

#include <opencv2/opencv.hpp>
#include <opencv2/viz/vizcore.hpp>
#include <iostream>

int main(int argc, char* argv[])
{
    cv::Mat image = cv::Mat::zeros(1024,1024, CV_8UC3);
    cv::viz::WImage3D imageWidget(image, cv::Size(1.0,1.0));

    for(int i = 0; i < 1E3; ++i)
    {
        imageWidget.setImage(image);
    }

    std::cout << "Press <RETURN> to exit...";
    std::cin.get();

    return 0;
}

Here is a description of my setup:
- OpenCV 2.4.9 (built from source)
- Ubuntu 12.04 x64
- CMake 2.8.12 (built from source)
- Qt 5.3.1 (x64 binary package)
- VTK 6.1.0 (built from source against the same Qt version)


Associated revisions

Revision 5c12c922
Added by Andrey Pavlenko almost 10 years ago

Merge pull request #3961 from apavlenko:2.4_fix_polylines_empty

Also available in: Atom PDF