dturing / node-gstreamer-superficial

Superficial gstreamer binding
MIT License
130 stars 45 forks source link

Memory Leak #17

Closed macdudeuk closed 7 years ago

macdudeuk commented 7 years ago

Hi

I am getting a consistent memory leak when pulling data from appsink. This is true using the example apps too. For instance if you run appsink.js with the following pipeline:

videotestsrc is-live=true ! appsink max-buffers=1 drop=true name=sink

Then it quickly eats all available memory.

Using node inspector, the leak does not seem to be in the node.js environment, and checking the code in GObjectWrap.cpp there is a call to gst_sample_unref() so I am confused where it is leaking.

Any help appreciated.

dturing commented 7 years ago

Hey,

i can't reproduce this yet, i tried the given pipeline on both linux and OSX; i'm monitoring memory usage with top/htop, and it seems constant while running for a minute or so.

Are you doing anything with the appsink buffers that might prevent them from getting garbage collected? Can you send an example script?

Edit: sorry, after re-reading your report, i tried with that exact pipeline in appsink.js. Still can't observe any leaking though. Can you tell me a bit about your environment? OS, Gstreamer version, node version?

Another edit: Seems i was looking in the wrong spot. I can see memory filling up now. I'll see if i can find anything..

dturing commented 7 years ago

turns out, if you gst_buffer_map(), you should also gst_buffer_unmap().

just as a sidenote: we could probably avoid the memcpy implied in Nan::CopyBuffer by deferring gst_buffer_unmap to a Nan::FreeCallback

thanks for reporting!

macdudeuk commented 7 years ago

That was quick!

Thanks for that.

/A