[gst-devel] Gst-python object cleanup

Ron McOuat rmcouat at smartt.com
Thu Oct 29 10:08:44 CET 2009


Hello Python gstreamer devs, users,

I have a long running application written in Python recording from a 
live source which is an IP camera such as what Axis produces. The video 
source is connected to a tee sink pad after processing and then from one 
of the tee src pads I dynamically connect a queue, Arnout's resettime, 
matroska mux and filesink to store the mjpeg stream. When I am done with 
one file recording I remove the recording bin by disconnecting from the 
tee and removing the bin from the pipeline. When I need to record again 
I build a new recording bin and attach to the tee. The next file could 
start recording on the next frame from the source so I use pad blocking 
during the record bin swap.

This is all working properly for me at this point except for one thing. 
As part of the stress testing phase I set the program to stop the 
recording bin and create a new one once per minute. What I find is the 
bin number and bus numbers in the recording bin detected by Python print 
bus or print bin are increasing with each cycle and the program slowly 
grows. After 12 hours of this the program has gone from 10 MBytes to 
about 40 MBytes. This is enough of a memory leak to eventually cause me 
problems. Most of the example programs I see are short lived and cleanup 
by exiting.

When I destroy a record bin I remove it from the pipeline and set the 
state to gst.STATE_NULL and have added code to unlink all the elements 
inside the bin and then remove the elements from the bin. Finally I set 
the Python variable holding the recording bin to None. Is there 
something I missed in the cleanup process possibly equivalent to the C 
unref on a Gobject? I am presuming the Python elements, bins and 
pipeline etc are proxy objects that are wrappers to the C objects. I 
have also considered that maybe I shouldn't be doing this in this manner 
but I ran into lots of time issues trying to reuse the recording bin.

Thanks for any suggestion.

Ron McOuat






More information about the gstreamer-devel mailing list