ros-drivers / video_stream_opencv

A package to open video streams and publish them in ROS using the opencv videocapture mechanism
227 stars 159 forks source link

Fixing ever growing memory when using boost::sync_queue #20

Closed Axel13fr closed 6 years ago

Axel13fr commented 6 years ago

The code does exacly the same thing, except that locks are done once per consum/produce cycle. It fixes as well a possible edge case where the user sets a queue size of 1 and 2 calls of pull can happen on after the other from the 2 different threads, leading the second pull to return either the previous picture (consumer pulls last) or an empty image (producer pulls last).

The growing memory comes from the boost implementation at least using the upstream Ubuntu 16.04 version of Boost (1.58.0.1).

awesomebytes commented 6 years ago

Hello, sorry for the late reply. I was away for a few weeks. Thank you for your PR. I'll give it a try to see if in my manual tests it behaves the same as before (but without the growing memory issue).

About the addition of the C++11 flag in the CMakeLists.txt, do you know if that can have any backwards compatibility problem? This package is supported on ROS Indigo (Ubuntu 14.04) and I'd like it to stay so for now.

awesomebytes commented 6 years ago

Ok, tried the different examples and different buffer sizes. Gonna send jobs to try a pre-release and releases soon.