pylon_gstreamer icon indicating copy to clipboard operation
pylon_gstreamer copied to clipboard

Fix memory leak in retrieve_image

Open TobiasSchaffner opened this issue 6 years ago • 2 comments

I think that there is a memory leak in retrieve_image. After running your project for more than a couple of hours I noticed that the application was eating up gigabytes of ram.

The problem seems to be how you handle the image buffer. I am not an gstreamer expert but I think somebody has to call gst_buffer_unref on this when the buffer is not needed anymore (somewhere after the signal emit).

You could do this by hand but I decided to use the gst_app_src_push_buffer method which takes ownership of the buffer and takes care that the buffer is unrefed implicitly.

TobiasSchaffner avatar Nov 29 '19 08:11 TobiasSchaffner

Hi Tobias! Thank you for picking this up! I see, yes you're correct about the implementation. I should do an unref when pushing via the signal. But I have not seen a memory leak like this before... could you tell me the hw platform/OS you're using, and also the pipeline you're testing with? Just so I don't forget (and to learn), I'd like to try and reproduce this before I pull in. Thank you again for spotting this! -Matt

MattsProjects avatar Dec 02 '19 21:12 MattsProjects

Hello Matt,

I am working on a x86_64 Debian Stretch with a Basler daA1920-30um camera.

The pipeline looks like this: queue, videoscale, capsfilter, videoconvert, x264enc, udpsink

Ask anytime if you need more information!

Greetings, Tobias

TobiasSchaffner avatar Dec 06 '19 08:12 TobiasSchaffner