After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 673509 - (Daniela) Memory leak in rtspsrc - opening from SDP
Memory leak in rtspsrc - opening from SDP
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
Other All
: Normal normal
: 0.10.32
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Reported: 2012-04-04 14:20 UTC by Daniela
Modified: 2012-09-07 14:16 UTC
See Also:
GNOME target: ---
GNOME version: ---

Description Daniela 2012-04-04 14:20:29 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;

  /* 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 */
    /* 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?
Comment 1 Daniela 2012-04-23 13:54:37 UTC
Originally put Windows as OS since this bug has been reproduced on it, but reasonably it affects other OSes too: changed to "All".
Comment 2 Wim Taymans 2012-09-07 14:16:57 UTC
commit 180e42b381a10b61e36a672c806ed59c0d72ae26
Author: Daniela <>
Date:   Fri Sep 7 16:15:42 2012 +0200

    rtspsrc: avoid leak
    When setup fails, make sure to cleanup afterwards.