Memleak debugging

Florian Echtler floe at butterbrot.org
Tue Sep 6 06:39:16 UTC 2022


Hi everyone,

I noticed a resource leak in my Python-based WebRTC application after extended 
runtime; it hangs with the repeated error message "gst_poll_read_control: 
assertion 'set != NULL' failed". AFAICT this likely means that too many GstBus 
objects or bus watches are still hanging around.

I've taken care to cleanup all resources when a client disconnects and I've 
verified this via the debug dot graph; there are no unexpected elements or pads 
hanging around anymore.

However, when I use the leak tracer, then it complains about a huge amount of 
leaks, including all the elements I supposedly removed (e.g. after 4 clients 
have connected and disconnected, the leak tracer shows 4 leaked GstWebRTCBin 
objects).

Here's a snippet from the code I use to tidy up after a client disconnects:

         # pause the bin
         self.wrb.bin.set_state(Gst.State.NULL)

         # pause, unlink, and remove the output buffers
         logging.debug("  Removing outputs...")
         for i in self.outputs:
             out_tee = self.outputs[i]
             out_tee.set_state(Gst.State.NULL)
             for p in out_tee.srcpads:
                 p.unlink(p.get_peer())
             remove_element(out_tee)

         # remove the bin
         logging.debug("  Removing main bin...")
         remove_element(self.wrb.bin)

AFAICT, if I stop and remove a bin, then it should deal with its internal 
components on its own, correct? Is there something I'm missing? I did not use 
blocking pad probes here because I don't care about buffers getting lost at this 
point.

Any hints welcome!

For reference, the full code is here: 
https://github.com/floe/surfacestreams/blob/main/client.py#L84-L140

Thanks and best, Florian
-- 
SENT FROM MY DEC VT50 TERMINAL
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 203 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220906/a7e28c83/attachment.sig>


More information about the gstreamer-devel mailing list