Element::set_state() leaks memory (increases ref_count of element (nd pipeline))
Call to Element::set_state()
seems to leak because the reference counter of the pipeline rises on every call.
To prove this see this example:
use gst::{prelude::*, State};
gst::init().unwrap();
let pipeline = gst::parse_launch(
r#"
videotestsrc
is-live=true
! queue
name=element
! xvimagesink
"#,
)
.unwrap()
.downcast::<gst::Pipeline>()
.expect("not a pipeline");
pipeline.set_state(State::Playing).unwrap();
let element = pipeline.by_name("element").unwrap();
eprintln!("initial ref_count = {c:>2}", c = pipeline.ref_count());
for _ in 0..10 {
pipeline.set_state(State::Paused).unwrap();
eprintln!(" paused ref_count = {c:>2}", c = pipeline.ref_count());
pipeline.set_state(State::Playing).unwrap();
println!("playing ref_count = {c:>2}", c = element.ref_count());
}
which' output is:
initial ref_count = 4
paused ref_count = 5
playing ref_count = 9
paused ref_count = 6
playing ref_count = 11
paused ref_count = 7
playing ref_count = 13
paused ref_count = 8
playing ref_count = 17
paused ref_count = 10
playing ref_count = 19
paused ref_count = 11
playing ref_count = 21
paused ref_count = 12
playing ref_count = 21
paused ref_count = 13
playing ref_count = 25
paused ref_count = 14
playing ref_count = 26
paused ref_count = 15
playing ref_count = 28
Expected would be to have a constant ref counter of element
at all the time.
Running this 1000 times (instead of 10 times) leads to this memory graph:
Graph generated from this file: massif.out.347360
Edited by Patrick Hoffmann