GNOME Bugzilla – Bug 638914
Stopping and starting multiple time leaks resources
Last modified: 2012-11-16 11:32:51 UTC
In my setting I must be able to totally deinitialize the server when not in use to conserve resources (embedded in Android app). Simply unreffing the server doesn't help. It doesn't close it's listening socket, so when started the next time the listening port is already in use. The server also has refs to GIOChannel and GSource which are never unreffed from what I can see. For now, I've added code close the listening socket and unref GIOChannel and GSource in gst_rtsp_server_finalize. It seems to work, but I'm a glib noob, so I could be horribly wrong. The caller of gst_rtsp_server_attach is responsible for detaching the server from its context. If not done, GIOChannel and GSource will be left with ref_count 1. My updated gst_rtsp_server_finalize: static void gst_rtsp_server_finalize (GObject * object) { GstRTSPServer *server = GST_RTSP_SERVER (object); g_free (server->address); g_free (server->service); g_object_unref (server->session_pool); g_object_unref (server->media_mapping); if (server->io_watch) g_source_unref (server->io_watch); if (server->io_channel) g_io_channel_unref (server->io_channel); if (server->server_sock.fd >= 0) close (server->server_sock.fd); }
for starters, it was missing a parent call to finalize. commit 0ef53a2d4f2db0ab6d5361971da53e39b0734dba Author: Wim Taymans <wim.taymans@collabora.co.uk> Date: Wed Jan 12 16:38:34 2011 +0100 server: chain up to the parent finalize
I added some more fixes. There is also an example for doing proper cleanup`in tests/test-cleanup.c
assuming it's fixed