GNOME Bugzilla – Bug 760289
rtpvrawdepay : memory leak
Last modified: 2016-01-11 23:12:54 UTC
Using gstvraw pay/depay cause a huge memory leak. Source : gst-launch-1.0 videotestsrc ! video/x-raw, width=320, height=240, format=I420 ! rtpvrawpay ! udpsink port=1234 Sink: gst-launch-1.0 udpsrc port=1234 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, sampling=(string)YCbCr-4:2:0, depth=(string)8, width=(string)320, height=(string)240, colorimetry=(string)BT601-5, payload=(int)96" ! rtpvrawdepay ! videoconvert ! xvimagesink Valgrind gives error in gst_rtp_vraw_depay_process_packet in gstvrawdepay.c ==12273== 27,141,368 (3,665,200 direct, 23,476,168 indirect) bytes in 13,475 blocks are definitely lost in loss record 2,518 of 2,518 ==12273== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==12273== by 0x53F9610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) ==12273== by 0x540F22D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) ==12273== by 0x4E7081E: gst_buffer_new (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.701.0) ==12273== by 0x4E735D3: gst_buffer_copy_region (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.701.0) ==12273== by 0x8ADF43B: gst_rtp_vraw_depay_process_packet (in /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstrtp.so) ==12273== by 0x941674E: gst_rtp_base_depayload_handle_buffer.isra.4 (in /usr/lib/x86_64-linux-gnu/libgstrtp-1.0.so.0.701.0) ==12273== by 0x4EA5406: gst_pad_push_data (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.701.0) ==12273== by 0x4EAD3AD: gst_pad_push (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.701.0) ==12273== by 0x7C860A4: gst_base_src_loop (in /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0.701.0) ==12273== by 0x4ED7320: gst_task_func (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.701.0) ==12273== by 0x541988B: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) I could solve problem adding gst_buffer_unref (buf) before each return
Created attachment 318440 [details] [review] rtpvrawdepay: fix major memory leak and performance issue Oops, nice catch. This should fix it. Was caused by the meta-copying code. The code is still a bit puzzling in that respect, need to check with Sebastian what the intention here was.
Created attachment 318448 [details] [review] patches for some other rtp depayloaders
Tim, you're working on this, right?
yes.
commit a8b864397764af49aa7827056e6c799175b38f39 Author: Tim-Philipp Müller <tim@centricular.com> Date: Thu Jan 7 20:27:29 2016 +0000 rtpvrawdepay: fix major memory leak and performance issue We call gst_rtp_buffer_get_payload() which creates a sub-buffer of each input buffer, just to copy over metas, and then leak it. https://bugzilla.gnome.org/show_bug.cgi?id=760289