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 [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
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): Michael www.ridgerun.com On 17 Jan 2021, at 11:16, jackBuffington <[hidden email]> wrote:
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by jackBuffington
Hi,
what definitely won't work is using gst_deinit followed by gst_init. This has often been commented on that this does not work Gruesse -----Ursprüngliche Nachricht----- Von: gstreamer-devel <[hidden email]> Im Auftrag von jackBuffington Gesendet: Sonntag, 17. Januar 2021 18:16 An: [hidden email] Betreff: Memory leak when repeatedly starting and stopping pipelines? 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: https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgstreamer-devel.966125.n4.nabble.com%2F&data=04%7C01%7C%7Cffe680580dab457c2a7008d8bb15fa0b%7C28042244bb514cd680347776fa3703e8%7C1%7C0%7C637465050347365393%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=5NNZ%2Bit0tlcpEu0krqY0wgc3TlLpOWiXZa%2B6pu1QcIM%3D&reserved=0 _______________________________________________ gstreamer-devel mailing list [hidden email] https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fgstreamer-devel&data=04%7C01%7C%7Cffe680580dab457c2a7008d8bb15fa0b%7C28042244bb514cd680347776fa3703e8%7C1%7C0%7C637465050347365393%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=dlf9qJ4KH7K%2FZw3yQl7ZxxULXAx4lebS%2FHiDpRpmg5k%3D&reserved=0 _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |