Memory leak when repeatedly starting and stopping pipelines?

Michael Gruner michael.gruner at ridgerun.com
Sun Jan 17 17:32:32 UTC 2021


Setting the pipeline to NULL and then unreffing it is the correct way (assuming there’s not something else in your code).

The leak may very easily be in one of the elements in the pipeline. This is specially true if you are using third party plug-ins. I recommend trying the super useful “leaks” tracer. Something like:

GST_TRACER=leaks GST_DEBUG=GST_TRACER:7 ./app

Additionally, here’s a guide on how to analyze a GStreamer application with Valgrind (it can be tricky):

https://developer.ridgerun.com/wiki/index.php?title=How_to_Analyze_Gstreamer_with_Valgrind

Michael
www.ridgerun.com

> On 17 Jan 2021, at 11:16, jackBuffington <jbuffington at redzone.com> wrote:
> 
> 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/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20210117/34818aa3/attachment.htm>


More information about the gstreamer-devel mailing list