GNOME Bugzilla – Bug 673509
Memory leak in rtspsrc - opening from SDP
Last modified: 2012-09-07 14:16:57 UTC
I have a video-surveillance application based on gstreamer with rtspsrc as source element. Playing many instances of a video from the same codec (which lead to some troubles when exceeding a fixed number of concurrent connections), I obtain the following errors from rtspsrc: WARN rtspsrc gstrtspsrc.c:5185:gst_rtspsrc_setup_streams:<rtsp-source> error: Error (400): Bad Request ERROR rtspsrc gstrtspsrc.c:5385:gst_rtspsrc_open_from_sdp:<rtsp-source> setup failed WARN rtspsrc gstrtspsrc.c:5580:gst_rtspsrc_open:<rtsp-source> can't setup streaming from sdp or something similar. To be more precise, in case of rtsp errors on the bus handler, I try to reconnect by stopping and playing the pipeline again, which often causes the above errors with this specific codec. Anyway, under this scenario I noticed a consistent increase of handles and memory usage, which is not recovered even after stopping all videos. Looking at the code before the error in gst_rtspsrc_open_from_sdp (gstrtspsrc.c), I've seen that memory for streams structures is allocated in gst_rtspsrc_create_stream, but not released after gst_rtspsrc_setup_streams fails. I tried to fix this by adding a call to gst_rtspsrc_cleanup in setup_failed error handling, and it seems to work. Just pasting a chunk of code to be clearer: --------------------- /* create streams */ n_streams = gst_sdp_message_medias_len (sdp); for (i = 0; i < n_streams; i++) { gst_rtspsrc_create_stream (src, sdp, i); } src->state = GST_RTSP_STATE_INIT; GST_OBJECT_FLAG_SET (src, GST_ELEMENT_IS_SOURCE); /* setup streams */ if (!gst_rtspsrc_setup_streams (src)) goto setup_failed; /* reset our state */ src->need_range = TRUE; src->skip = FALSE; src->state = GST_RTSP_STATE_READY; return TRUE; /* ERRORS */ setup_failed: { /* DANIELA: cleanup previously allocated stream structures */ gst_rtspsrc_cleanup (src); /**/ GST_ERROR_OBJECT (src, "setup failed"); return FALSE; } --------------------- Is this correct or am I missing something? Thanks.
Originally put Windows as OS since this bug has been reproduced on it, but reasonably it affects other OSes too: changed to "All".
commit 180e42b381a10b61e36a672c806ed59c0d72ae26 Author: Daniela <daniela.muzzu@selexelsag.com> Date: Fri Sep 7 16:15:42 2012 +0200 rtspsrc: avoid leak When setup fails, make sure to cleanup afterwards. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=673509