int main()
{
cv::Mat x;
std::string path{"a_video.file"};
cv::VideoCapture * cap1 = new cv::VideoCapture(path);
cap1->read(x);// comment this it wont happen
cv::VideoCapture * cap2 = new cv::VideoCapture(path);
cap2->read(x);// comment this it wont happen
cv::VideoCapture * cap3 = new cv::VideoCapture(path);
cap3->read(x);// comment this it wont happen
cv::VideoCapture * cap4 = new cv::VideoCapture(path);
cap4->read(x);// comment this it wont happen
cv::VideoCapture * cap5 = new cv::VideoCapture(path);
cap5->read(x); // comment this it wont happen
delete cap1;
delete cap2;
delete cap3;
delete cap4;
delete cap5;
//CV_VERSION 4.6.0 on ubuntu 16.04
return 0;
}
this code will cause memory leak.the more new object the more memory consuming.
when comment all the read() functions , it doesnt.
is this a feature or bug ?
hope you guys check this problem.thanks!
hello. i dont know which backend i’m using . and this code auto find a backend to open my video.file.
measurement is the monitor on ubuntu.(i watched at it ! - -)
if you work on ubuntu , you can have a try ! just prepare any video file (best 4k) thank you !
thank you!
at first i think so.
but when i delete the videocapture, the “buffer” still exsit, so that makes me ask you for help.
and how can i remove the buffer when i dont need this videocapture any more?
i watch at it through the monitor on ubuntu16.04.when i place break point on each “read()” sentence, the memory goes high after every “read()”, and it wont goes down after delete that videocapture object. even reach out the return of main function. the memory wont goes down.
this app’s just do the code below and it wont release the memory when reach out the return .
int main()
{
cv::Mat x;
std::string path{"a_video.file"};
cv::VideoCapture * cap1 = new cv::VideoCapture(path);
cap1->read(x);// comment this it wont happen
cv::VideoCapture * cap2 = new cv::VideoCapture(path);
cap2->read(x);// comment this it wont happen
cv::VideoCapture * cap3 = new cv::VideoCapture(path);
cap3->read(x);// comment this it wont happen
cv::VideoCapture * cap4 = new cv::VideoCapture(path);
cap4->read(x);// comment this it wont happen
cv::VideoCapture * cap5 = new cv::VideoCapture(path);
cap5->read(x); // comment this it wont happen
delete cap1;
delete cap2;
delete cap3;
delete cap4;
delete cap5;
//CV_VERSION 4.6.0 on ubuntu 16.04
return 0;
}
values in a System Monitor do not indicate memory leaks.
they indicate that the process still holds onto the memory, perhaps to reuse it later.
your “methodology” (exactly five instantiations) is invalid. run that stuff in an infinite loop, in the same process. if that causes continuously growing RAM usage, then you have a memory leak. it will not though.
basically… you won’t find a memory leak because smarter people would have found it already, and they didn’t, so there isn’t one. you would need to learn a lot more about memory leaks to understand what is a memory leak and what isn’t.