Memory Leak in Mat::copyTo()

asked 2015-09-16 09:46:48 -0600

iEng gravatar image

I have a vector of images (called images) in OpenCV 3.0.0, which I iterate through in the way shown below. Please disregard, that this code makes no actual sense, I stripped it to point out the problem. Strangely, with each run the memory usage increases, even after the loop has completed. The way I see it, memory should stay the same, since the images in the images-vector are replaced. Manually releasing the matrices does not work either. What can I do to achieve constant memory usage.

for (int i = 0; i < num_images; ++i)
{
    Mat cropped_image;
    images[i].copyTo(cropped_image);
    images[i] = cropped_image;
}
edit retag flag offensive close merge delete

Comments

can't reproduce it on win - constant mem usage here.

berak gravatar imageberak ( 2015-09-17 00:38:39 -0600 )edit

This results in a memory leak if one is a UMat and the other is a Mat. I ran into this problem and posted a question with some additional memory diagnostics from VS 2015 here. http://answers.opencv.org/question/78...

Steve Hess gravatar imageSteve Hess ( 2015-12-11 19:19:27 -0600 )edit