Memory leak when repeatedly starting and stopping pipelines?

jackBuffington jbuffington at redzone.com
Sun Jan 17 17:16:12 UTC 2021


I have a program that I have written that repeatedly starts and stops some
relatively complex pipelines.   Everything is working but in my final
testing, I have found that around the 38th time I do this, the program
becomes unstable and crashes.  When I use htop (I'm working in linux) to
look at system resources, it seems that every time I launch a new pipeline,
all of the gstreamer threads that are spawned use just a little more memory. 
I'm assuming that this isn't an issue with Gstreamer but rather with how I
am using it.  

When starting pipelines, I am creating my pipeline in C++ using
gst_parse_launch().  I then set it to the READY state and then the PLAY
state.   When shutting down, I was sending an EOS and then setting the
pipeline to NULL and then calling gst_object_unref ().   

Suspecting that this isn't quite the correct way even though it is what is
shown in all of the demo code that I have seen, I tried sending an EOS and
then setting its state to PAUSED then READY then NULL but that seems to
leave straggler elements still running and I can only launch and kill four
pipelines before the program fails.    I've also tried sending an EOS then
READY then NULL but only get about five pipelines before it fails.  

I've also tried gst_deinit() followed by a new gst_init thinking that if I
blow away all Gstreamer stuff entirely then that really ought to clear up
the problem but that doesn't work past the first pipeline.  

So...  What is the correct way to shut down a pipeline to not have the
memory issue that I am seeing?  Have any of you experienced this?  I would
think that it would be a fairly common thing to be switching the pipelines
that are being used as a program runs.   



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list