I am wondering that what is the reason for dramatical memory using Java program with OpenCV, If only read and show the image, then no problem, but when I want to perform so operation, such as
Background Subtraction -> cleaning operation (`OPEN`, `CLOSE`, etc) -> find counters -> draw contours
I tried my best to write the most optimized code (avoiding newing Mat in every loop, trying to reuse the previous object etc), so for example, if I have 8GB RAM
, then in every second the memory used about 40Mb, then in few minutes the RAM
become 100%.
My question is: what is wrong whit OpenCV
in Java
, Or what should I do with Mats
objects? Does Mat
object need to be released after every loop? Or I must not use the global Mat
object in every loop, in this case, I must new a Mat
in every loop?
OpenCV version is: 3.331