Re: Release RAM, when close or reload stream
Aleksandr Slobodeniuk via gstreamer-devel <[email protected]> Wed, 17 Apr 2024 17:51:00 +0200
| Newsgroups | gmane.comp.video.gstreamer.devel |
|---|---|
| Message-ID | <CAHuwaLBZKM2qVdT5jDo0qHJRJ-ptnoUncBzzW3qx7E+mp3KU_A@mail.gmail.com> |
Hi, this really sounds like a memory leak. Quite likely that this will help: 1. set environment variables GST_TRACERS="leaks(name=all-leaks)" GST_DEBUG=GST_TRACER:7 2. make sure that your application calls `gst_deinit()` before it terminates. 3. run your app for a while (sounds like just opening 2 streams is enough), and then close it (so everything gstreamer-related is supposed to be freed, and the gst_deinit() is called afterwards). If some of the objects (such as elements, buffers) remain alive (it means there was a leak) at the moment of gst_deinit(), it will print a warning to stderr, and will log each object in the gstreamer log (also stderr by default). If you have done all the steps and do not see any leak, it's quite useful to add a leak on purpose to make sure the method works on your system. Like just adding an extra ref on something. If it still only shows the leak you add on purpose, consider building your project with address sanitizer, this will catch all the leaks, not only in the GStreamer-related objects. Kind Regards, Aleksandr Slobodeniuk Senior Software Engineer +34 936 03 42 35 Carrer de Jordi Girona, 29 08034, Barcelona, Spain. <http://fluendo.com> <https://es.linkedin.com/company/fluendo> <https://twitter.com/fluendo> <https://github.com/fluendo> On Wed, Apr 17, 2024 at 4:15 PM Deymos s via gstreamer-devel < [email protected]> wrote: > I am developing a video wall for 32-64 streams, I faced the problem of > increasing memory when restarting streams I have an example illustrating my > problem. > Example: https://github.com/Deymoss/Rtsp-player > > When I start the application, a pipeline is created, as a result, the > application initially takes 54MB of RAM, when I start the stream, the > volume increases to ~ 110 MB, when I close the stream, the memory is not > freed, when I run the same stream again, the amount of RAM increases to 120 > MB, and so on, 36 streams eats 5 gb RAM for 12 hours, the same is true for > file files descriptors (I suspect BUS creates them) > > How to properly clear the memory and all information about the stream when > closing? > > At the moment I'm setting the pipeline to NULL and not making an unref, > but if I uncomment these lines: > > gst_bus_set_sync_handler(m_videoPipe->bus, nullptr, nullptr, nullptr);gst_object_unref(m_videoPipe->pipeline);gst_object_unref(m_videoPipe->bus); > > nothing changes in memory consumption, although the refcount of each > element and the pipeline itself at the end of the function is zero. >