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;
}