Memory leak problem - refcount

Julio jeloguin at
Thu Oct 8 05:52:37 PDT 2015

Hi guys.

I have a problem with a pipeline.

The pipeline looks like this:

And custom bin is:

Initially, valve is dropping frames.

Then, when user wants, I make the folowing stuff:

// Disable the drop
g_object_set(G_OBJECT(valve), "drop", 0, NULL);
// Receive the buffer in appsink
// Unref the buffer
// Enable the drop
g_object_set(G_OBJECT(valve), "drop", 1, NULL);
// Unlink the bin
gst_element_unlink(valve, snapshot_bin);
// Set it to NULL
gst_element_set_state(snapshot_bin, GST_STATE_NULL);
// Link again the bin
gst_element_link(valve, snapshot_bin);
// Run the bin
gst_element_set_state(snapshot_bin, GST_STATE_PLAYING);

This code works ok, but every time I call it the ram is increased ... so I
have a memory leak.

I have noticed that, the ref count of several elements( snapshot_bin,
rtph264depay, avdec_h264, videorate, appsink)  is increased when I use this
gst_element_set_state(snapshot_bin, GST_STATE_NULL);
gst_element_set_state(snapshot_bin, GST_STATE_PLAYING);

And, afer 20 executions, I can have refcount of snapshot_bin to 120 ( The
ref count of the rest of the elements is fixed in 4 ) ... and I think this
is the cause of the memory leak ...

Can you help me with that ?

Thanks a lot !!!

View this message in context:
Sent from the GStreamer-devel mailing list archive at

More information about the gstreamer-devel mailing list