Not sure if this is relevant, but I'm using opencv4nodejs
for my project, and I did run in this situation where if I don't call .release()
on each Mat object, the memory consumption goes up ~10MB/s.
This simple example code will crate the issue.
function loop(camera, display)
{
let mat = camera.read();
let grey_mat = mat.bgrToGray();
loop(camera, display);
}
Where as, this one fixes the problem:
function loop(camera, display)
{
let mat = camera.read();
let grey_mat = mat.bgrToGray();
grey_mat.release();
mat.release();
loop(camera, display);
}
If I search for why OpenCV Mat object causes leeks I get answers where people say that Mat is capable of taking care of memory usage on its own.
If the last statement is true, what am I doing wrong? And if I'm not doing anything wrong, why do I have to explicitly tell a Mat object to release its memory? Or, is there a potential issue with the npm module opencv4nodejs
itself?
from Why OpenCV Mat creates memory leeks?
No comments:
Post a Comment