<div>Hi,</div>
<div>&nbsp;</div>
<div>I would like to run a pipeline several times in a program. The problem is that when a pipeline ends,&nbsp;and&nbsp;even if I free it with gst_object_unref, a part of the memory is not freed.</div>
<div>Above is the really simple code I use to test this memory leak problem.</div>
<div>&nbsp;</div>
<div>Thank you for your help,</div>
<div>Antoine Tarault</div>
<div>&nbsp;</div>
<div>
<p>#include &lt;gst/gst.h&gt;</p>
<p>void gstMain()<br>{<br>&nbsp;GstClock *clock;<br>&nbsp;GstClockID clock_id;<br>&nbsp;GstClockReturn wait_ret;<br>&nbsp;GstElement&nbsp;*pipeline = NULL;<br>&nbsp;GstElement&nbsp;*video_src = NULL;<br>&nbsp;GstElement&nbsp;*video_sink = NULL;<br>&nbsp;gboolean&nbsp;res;</p>

<p>&nbsp;gst_init(NULL, NULL);</p>
<p><br>&nbsp;pipeline = gst_pipeline_new(&quot;avd_pipeline&quot;);</p>
<p>&nbsp;video_src = gst_element_factory_make(&quot;videotestsrc&quot;, &quot;filesrc_avi&quot;);<br>&nbsp;if (video_src == NULL)<br>&nbsp;{<br>&nbsp;&nbsp;g_print(&quot;Error creating plugin type videotestsrc\n&quot;);<br>&nbsp;&nbsp;return;<br>&nbsp;}</p>
<p>&nbsp;video_sink = gst_element_factory_make(&quot;directdrawsink&quot;, &quot;video_sink&quot;);<br>&nbsp;if (video_sink == NULL)<br>&nbsp;{<br>&nbsp;&nbsp;g_print(&quot;Error creating plugin type directdrawsink\n&quot;);<br>&nbsp;&nbsp;return;<br>&nbsp;}</p>

<p>&nbsp;gst_bin_add_many(&nbsp;GST_BIN(pipeline), <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;video_src,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;video_sink,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NULL);</p>
<p>&nbsp;res = gst_element_link(video_src,video_sink);<br>&nbsp;if(!res)<br>&nbsp;{<br>&nbsp;&nbsp;g_print(&quot;error linking video src to video sink&quot;);<br>&nbsp;&nbsp;return;<br>&nbsp;}</p>
<p>&nbsp;clock = gst_pipeline_get_clock (GST_PIPELINE (pipeline));<br>&nbsp;if(pipeline == NULL)<br>&nbsp;{<br>&nbsp;&nbsp;fprintf (stderr, &quot;FREEING pipeline ...\n&quot;);<br>&nbsp;&nbsp;gst_object_unref(pipeline);<br>&nbsp;&nbsp;return;<br>&nbsp;}</p>
<p>&nbsp;clock_id =<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gst_clock_new_single_shot_id (clock,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gst_clock_get_time (clock) + (7 * GST_SECOND));<br>&nbsp;gst_object_unref(clock);<br>&nbsp;<br>&nbsp;if (gst_element_set_state (pipeline, GST_STATE_PLAYING)) {<br>&nbsp;&nbsp;if ((wait_ret = gst_clock_id_wait (clock_id, NULL)) != GST_CLOCK_OK) 
<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;GST_WARNING (&quot;clock_id_wait returned: %d&quot;, wait_ret);<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;fprintf (stderr, &quot;Setting pipeline to NULL ...\n&quot;);<br>&nbsp;&nbsp;gst_element_set_state(pipeline, GST_STATE_NULL);</p>
<p>&nbsp;&nbsp;fprintf (stderr, &quot;FREEING pipeline ...\n&quot;);<br>&nbsp;&nbsp;gst_object_unref(pipeline);<br>&nbsp;}<br>&nbsp;return;<br>}</p>
<p><br>int main()<br>{<br>&nbsp;gstMain();<br>&nbsp;g_usleep(1000000);<br>&nbsp;gstMain();<br>&nbsp;return 0;<br>}<br></p></div>