[gst-devel] Re: memory leak in a program

Jan Schmidt thaytan at noraisin.net
Wed Feb 8 01:25:05 CET 2006


gst_element_set_state (pipeline, GST_STATE_NULL) can return
GST_STATE_CHANGE_ASYNC to indicate that it's returning to NULL in a
background thread. In that case, you need to wait for the state change
to complete with gst_element_get_state, otherwise you'll exit the
program before the background thread has finished shutting down.

J. 

On Wed, 2006-02-08 at 08:23 +0100, Vincent Torri wrote:
> It seems that it suffices that decodebin is in the PAUSE state to have
> that leak. For example:
> 
> #include <gst/gst.h>
> 
> int
> main (int argc, char *argv[])
> {
>   GstElement *pipeline;
>   GstElement *filesrc;
>   GstElement *decodebin;
> 
>   gst_init (&argc, &argv);
> 
>   pipeline = gst_pipeline_new ("pipeline");
> 
>   filesrc = gst_element_factory_make ("filesrc", "filesrc");
>   g_assert (filesrc);
>   g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
> 
>   decodebin = gst_element_factory_make ("decodebin", "decodebin");
>   g_assert (decodebin);
> 
>   gst_bin_add_many (GST_BIN (pipeline), filesrc, decodebin, NULL);
>   gst_element_link (filesrc, decodebin);
> 
>   gst_element_set_state (pipeline, GST_STATE_PAUSED);
> 
>   gst_element_set_state (pipeline, GST_STATE_NULL);
>   gst_object_unref (pipeline);
> 
>   gst_deinit ();
> 
>   return 1;
> }
> 
> 
> Vincent
> 
> On Tue, 7 Feb 2006, Vincent Torri wrote:
> 
> >
> > hello, i'm writing a small program that print the informations of a media
> > file to a terminal (named eic_cli)
> >
> > when I run valgrind on it, I get some memory leak :
> >
> > http://rafb.net/paste/results/yGuWx426.html
> >
> > the program can be downloaded here :
> >
> > http://www.iecn.u-nancy.fr/~torri/files/eic-0.1.tar.gz
> >
> > i don't know if the problem comes from my program or gstreamer (0.10, cvs,
> > taken 2 days ago). When I quit the main function, I set the pipeline to
> > the NULL state and I unref it (lines 380 and 381 of eic.c). I don't know
> > if it's sufficient.
> >
> > Vincent Torri
> >
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> 

-- 
Jan Schmidt thaytan at noraisin.net

<stibbons> Yeah. The whole climax thing would make much more sense
if I'd paid attention.






More information about the gstreamer-devel mailing list