GNOME Bugzilla – Bug 782553
Resources are not being freed when using alsasink/pulsesink
Last modified: 2017-06-02 08:20:39 UTC
Hi, using Gstreamer 1.8.3 and gst-python 1.6.2 in Ubuntu 16.04 I see that launching a pipeline with audiotestsrc and alsasink or pulsesink doesn't free resources correctly. If I check the /proc/<PROC_ID>/fd of the python script, I notice that the opened files list grows each time I restart the pipeline. If I use the C bindings instead of Python it works correctly. I tried to create the pipeline in three different ways, and all seemed to give the same result. Gist with all the scripts used for testing. https://gist.github.com/dpeite/44f5b0d58b242d6ec1e47dcd88e77615 Tested in Python 2.7.12 so far. We will test it in Python 3 next week.
Tested in Python 3.5.2 and also didn't work. But if I use autoaudiosink instead of alsasink or pulsesink it works correctly on both Python versions.
I tested using alsasrc and pulsesrc instead of audiotestsrc and doesn't free resources. In summary: audiotestsrc --------- autoaudiosink = All ok, no new files audiotestsrc --------- pulsesink/alsasink = New files in each iteration alsasrc/pulsesrc ----- autoaudiosink = New files in each iteration alsasrc/pulsesrc ----- pulsesink/alsasink = New files in each iteration
I have tried executing the scripts with the gstreamer master branch and they seem to have the same issue. The python scripts create new files with each iteration and the C script does not.
Is there something else we can test to help narrow down the issue?
Just to let you know that I too ran into this problem and never really got around solving it. Note that calling self.pipeline.unref() explicitly does not free your handles and causes a refcount warning when the (python) process is finished. I see the same behavior when using a pipeline like videotestsrc - xvimagesink
This might also be related to floating references and how we have annotated them in GStreamer in the past. Sebastian did a whole bunch of fixes for that in git master, for what it's worth, so you might want to test with that as well.
Created attachment 352959 [details] [review] gst_bin_add: change the annotation to (transfer floating). The default implementation then goes on to call gst_object_set_parent, which is (transfer floating).
I've tested the master branch and the issue seems to be fixed. Should this change also be applied to the 1.8 branch (and 1.10, 1.12, ...)? I have patched and compiled the 1.8 with this change and it seems to also fix the issue, but I may be missing more fixes related to the annotations?
I'm not sure we want to push this to 1.12 as a point release change, so you might have to wait till 1.14 to have this in a stable release. Either way, it's unlikely we'll make backports to versions older than 1.12 (the overhead of maintaining more than one previous stable release is too high).
These changes are a bit intrusive, I don't think they'll be backported. Thanks for testing and confirming it's fixed in master!