memory leak with VideoCapture
Hello, I was debuging my code when I saw a memory leak with VideoCapture. There you have the memory of my computer : it's go up realy fast http://i.imgur.com/wXtpKS0.png
I tested this two code :
while (1) { VideoCapture test; test = VideoCapture(0); test.~VideoCapture(); }
while (1) { VideoCapture test; test = VideoCapture(0); test.release(); }
is this normal? do you have any solution?
Thank you
Its because you are trying to destroy the objects itself. This is not needed in OpenCV because going out of scope will trigger the garbage collector destroying the item itself and freeing the memory. Secondly, why do you create objects inside while loops?
yes, this is normal. (at least on some os / capture driver combination)
you're supposed to use exactly 1 instance of VideoCapture, and leave it alive for the duration of your program.
Thank you, here it's a simplification of my code, I found a solution by puting test in a static class, that permit to never recall it
btw, os / opencv version ?
@berak where I can find this info ? ...supposed to use exactly 1 instance of VideoCapture... should the doc be updated ?
Ooencv 310, visual studio 2015, vc14 ans windows 10
I did a test : i did 100 instance of vidéo capture, then did a pause and magic : the memory free itself. But i had to wait some seconds
And @pklab you can do instance as much as you want, the problème was the memory wasen't free just after they were release
@pklab, shame on me, but i made this up. and i guess it's much more of a problem with v4l on linux, than on win( dshow seems just slow, destroying the filtergraph)