"GStreamer" (bugzilla.gnome.org)
2012-09-06 09:07:26 UTC
https://bugzilla.gnome.org/show_bug.cgi?id=683470
GStreamer | gstreamer (core) | 0.11.x
Summary: Unix socket fd leaks and memory leaks when use
pipeline
Classification: Platform
Product: GStreamer
Version: 0.11.x
OS/Version: Linux
Status: UNCONFIRMED
Severity: critical
Priority: Normal
Component: gstreamer (core)
AssignedTo: gstreamer-***@lists.freedesktop.org
ReportedBy: ***@yahoo.com.cn
QAContact: gstreamer-***@lists.freedesktop.org
GNOME version: ---
We usually use the code as below.
//=====================================
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline,*source,*typefind,*sink;
gst_init(NULL, NULL);
loop = g_main_loop_new(NULL, FALSE);
//create element
pipeline = gst_pipeline_new("my_pipeline");
typefind = gst_element_factory_make("typefind","typefind1");
sink = gst_element_factory_make("fakesink","sink1");
source = gst_element_factory_make("souphttpsrc","source1");
if (!pipeline || !source || !typefind || !sink)
{
return;
}
g_object_set (G_OBJECT(source), "location", _cUrl, NULL);
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); //here will ref bus
gst_bus_add_watch(bus, bus_watch, loop); //here will ref
bus
gst_object_unref(bus); //but
only unref bus once
gst_bin_add_many(GST_BIN(pipeline), source, typefind, sink, NULL);
gst_element_link(source,typefind);
gst_element_link(typefind,sink);
g_main_loop_run(loop);
gst_element_set_state(pipeline,GST_STATE_NULL);
gst_object_unref(GST_OBJECT(pipeline));
//=====================================
Gstreamer example code is the same usage.
Note this:
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); //here will ref bus
gst_bus_add_watch(bus, bus_watch, loop); //here will ref
bus
gst_object_unref(bus); //but
only unref bus once
(gst_pipeline_get_bus --> gst_element_get_bus) will ref bus.
(gst_bus_add_watch ---> gst_bus_add_watch_full_unlocked--->
gst_bus_create_watch) will ref bus.
Then will ref bus twice, and only unref once. So when we call
"gst_object_unref(GST_OBJECT(pipeline));" at end of the application, the
pipeline bus will not freed.
When the pipeline created, it will create bus, and bus will create gstpoll.
look at gstpoll codes,
GstPoll *
gst_poll_new (gboolean controllable)
{
GstPoll *nset;
GST_DEBUG ("controllable : %d", controllable);
nset = g_slice_new0 (GstPoll);
g_mutex_init (&nset->lock);
#ifndef G_OS_WIN32
nset->mode = GST_POLL_MODE_AUTO;
nset->fds = g_array_new (FALSE, FALSE, sizeof (struct pollfd));
nset->active_fds = g_array_new (FALSE, FALSE, sizeof (struct pollfd));
nset->control_read_fd.fd = -1;
nset->control_write_fd.fd = -1;
{
gint control_sock[2];
if (socketpair (PF_UNIX, SOCK_STREAM, 0, control_sock) < 0)
goto no_socket_pair;
//=================================
It will use socketpair to create two sockets, but not closed when pipeline
destroyed because the bus ref count is 2.
You can use lsof to check fd number
GStreamer | gstreamer (core) | 0.11.x
Summary: Unix socket fd leaks and memory leaks when use
pipeline
Classification: Platform
Product: GStreamer
Version: 0.11.x
OS/Version: Linux
Status: UNCONFIRMED
Severity: critical
Priority: Normal
Component: gstreamer (core)
AssignedTo: gstreamer-***@lists.freedesktop.org
ReportedBy: ***@yahoo.com.cn
QAContact: gstreamer-***@lists.freedesktop.org
GNOME version: ---
We usually use the code as below.
//=====================================
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline,*source,*typefind,*sink;
gst_init(NULL, NULL);
loop = g_main_loop_new(NULL, FALSE);
//create element
pipeline = gst_pipeline_new("my_pipeline");
typefind = gst_element_factory_make("typefind","typefind1");
sink = gst_element_factory_make("fakesink","sink1");
source = gst_element_factory_make("souphttpsrc","source1");
if (!pipeline || !source || !typefind || !sink)
{
return;
}
g_object_set (G_OBJECT(source), "location", _cUrl, NULL);
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); //here will ref bus
gst_bus_add_watch(bus, bus_watch, loop); //here will ref
bus
gst_object_unref(bus); //but
only unref bus once
gst_bin_add_many(GST_BIN(pipeline), source, typefind, sink, NULL);
gst_element_link(source,typefind);
gst_element_link(typefind,sink);
g_main_loop_run(loop);
gst_element_set_state(pipeline,GST_STATE_NULL);
gst_object_unref(GST_OBJECT(pipeline));
//=====================================
Gstreamer example code is the same usage.
Note this:
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); //here will ref bus
gst_bus_add_watch(bus, bus_watch, loop); //here will ref
bus
gst_object_unref(bus); //but
only unref bus once
(gst_pipeline_get_bus --> gst_element_get_bus) will ref bus.
(gst_bus_add_watch ---> gst_bus_add_watch_full_unlocked--->
gst_bus_create_watch) will ref bus.
Then will ref bus twice, and only unref once. So when we call
"gst_object_unref(GST_OBJECT(pipeline));" at end of the application, the
pipeline bus will not freed.
When the pipeline created, it will create bus, and bus will create gstpoll.
look at gstpoll codes,
GstPoll *
gst_poll_new (gboolean controllable)
{
GstPoll *nset;
GST_DEBUG ("controllable : %d", controllable);
nset = g_slice_new0 (GstPoll);
g_mutex_init (&nset->lock);
#ifndef G_OS_WIN32
nset->mode = GST_POLL_MODE_AUTO;
nset->fds = g_array_new (FALSE, FALSE, sizeof (struct pollfd));
nset->active_fds = g_array_new (FALSE, FALSE, sizeof (struct pollfd));
nset->control_read_fd.fd = -1;
nset->control_write_fd.fd = -1;
{
gint control_sock[2];
if (socketpair (PF_UNIX, SOCK_STREAM, 0, control_sock) < 0)
goto no_socket_pair;
//=================================
It will use socketpair to create two sockets, but not closed when pipeline
destroyed because the bus ref count is 2.
You can use lsof to check fd number
--
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.