Gstreamer Rust memory leak

Guru Govindan gurunathan.govindan at
Tue Mar 29 08:18:49 UTC 2022

I am developing a pipeline to ingest a video stream from RTSP and create
dynamic ABR ladders that would mux audio and video and mux to hlssink.

I have a create_bin function that creates an Bin element containing

the queue sink is set as ghost pad like below
let video_ghost_pad = gst::GhostPad::with_target(Some("video"),

Then I add the Bin to the pipeline

I then add a probe to block downstream video from the video tee so that I
can link the video_tee src and ghost sink
let tee_video_pad = video_tee.request_pad_simple("src_%u").unwrap();

let video_block =
tee_video_pad.add_probe(gst::PadProbeType::BLOCK_DOWNSTREAM, |_pad, _info| {
I then link the src->sink between video-tee and my Bin
let video_sink_pad = enc_bin.static_pad("video").unwrap();;
I then call the call_async method on my Bin to sync state with parent.

enc_bin.call_async(move |bin| {
                if bin.sync_state_with_parent().is_err() {
                    log::error!("could not set the enc_bin_{} to playing",

Everything works fine until now. ( I see that the memory increases by about
100MB depending on the resolution).

When I call to remove this Bin from the pipeline,
I call pipeline.call_async a closure that contains code to block the
video_tee sink pad
let video_block =
video_tee_sink_pad.add_probe(gst::PadProbeType::BLOCK_DOWNSTREAM, |_pad,
_info| {
I then release the request src pad and remove probe
I then call unlink, remove and set the Bin I created to null

let res = pipeline.remove(&enc_bin);
// I compare the result here

let state_res = enc_bin.set_state(gst::State::Null);

Removing seems to work fine as well. However the memory that was allocated
during the creation of the ABR never gets released. I see that it keeps
increasing slowly.

Generating the debug_dump_dot file after removal shows that the bin and the
src pads dont exists anymore.

But everytime I create a new Bin, the memory increases and never releases.

FYI, I am using vaapi encoders for this.

I appreciate any help in this regard. It would be really helpful if you
could even provide any other tools that might help me with this!

Best Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gstreamer-devel mailing list