[FFmpeg-devel] FFMPEG RTSP memory leaks

Stas Oskin stas.oskin
Mon Aug 31 14:09:00 CEST 2009


Hi.

I suspected some memory leaks in ffmpeg RTSP reading functionality, and have
run it through valgrind.

It seems valgrind caught at least one possible leak, the details below.

Any idea if this a know issue, and there any fixes planned?

Thanks.


[stas at nctest ~]$ valgrind --leak-check=full ffmpeg -i rtsp://
192.168.253.150/axis test.mp4
==10732== Memcheck, a memory error detector
==10732== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==10732== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==10732== Command: ffmpeg -i rtsp://192.168.253.150/axis test.mp4
==10732==
FFmpeg version SVN-r19668-xuggle-3.2.814, Copyright (c) 2000-2009 Fabrice
Bellard, et al.
  configuration: --prefix=/usr --extra-version=xuggle-3.2.814
--extra-cflags=-I/home/NEO/stas/dev/xuggle/xuggler-3.2-dev/build/native/x86_64-unknown-linux-gnu/captive/usr/include
--extra-ldflags=-L/home/NEO/stas/dev/xuggle/xuggler-3.2-dev/build/native/x86_64-unknown-linux-gnu/captive/usr/lib
--enable-shared --enable-gpl --enable-nonfree --enable-version3
--enable-libx264 --enable-libmp3lame --enable-libvorbis --enable-libtheora
--enable-libspeex --enable-libfaac --enable-pthreads
  libavutil     50. 3. 0 / 50. 3. 0
  libavcodec    52.32. 0 / 52.32. 0
  libavformat   52.37. 0 / 52.37. 0
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0. 7. 1 /  0. 7. 1
  built on Aug 25 2009 18:47:45, gcc: 4.1.2 20080704 (Red Hat 4.1.2-44)
Input #0, rtsp, from 'rtsp://192.168.253.150/axis':
  Duration: N/A, start: 0.118444, bitrate: N/A
    Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 1k tbr,
90k tbn, 1k tbc
  Metadata
    title           : Media Presentation
File 'test.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'test.mp4':
    Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31,
200 kb/s, 1k tbn, 1k tbc
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
[mpeg4 @ 0x4c3f280]warning: first frame is no keyframe
[mpeg4 @ 0x4c887c0]Error, Invalid timestamp=0,
last=57itrate=2100.6kbits/s
Video encoding failed
==10732==
==10732== HEAP SUMMARY:
==10732==     in use at exit: 2,556,306 bytes in 183 blocks
==10732==   total heap usage: 582 allocs, 399 frees, 2,943,995 bytes
allocated
==10732==
==10732== 213 (56 direct, 157 indirect) bytes in 1 blocks are definitely
lost in loss record 15 of 123
==10732==    at 0x4A05016: memalign (vg_replace_malloc.c:532)
==10732==    by 0x4A0506F: posix_memalign (vg_replace_malloc.c:660)
==10732==    by 0x3EB8805F1C: av_malloc (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB8805FB4: av_mallocz (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB781B506: av_set_parameters (in
/usr/lib/libavformat.so.52.37.0)
==10732==    by 0x4065CB: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x40ECBE: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x40A6A5: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x3D1721D8B3: (below main) (in /lib64/libc-2.5.so)
==10732==
==10732== 256 bytes in 1 blocks are definitely lost in loss record 22 of 123
==10732==    at 0x4A05016: memalign (vg_replace_malloc.c:532)
==10732==    by 0x4A0506F: posix_memalign (vg_replace_malloc.c:660)
==10732==    by 0x3EB8805F1C: av_malloc (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB8805FB4: av_mallocz (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB7CD880F: MPV_common_init (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7CF6534: MPV_encode_init (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7C911EF: avcodec_open (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x40B44D: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x3D1721D8B3: (below main) (in /lib64/libc-2.5.so)
==10732==
==10732== 1,024 bytes in 1 blocks are definitely lost in loss record 53 of
123
==10732==    at 0x4A05016: memalign (vg_replace_malloc.c:532)
==10732==    by 0x4A0506F: posix_memalign (vg_replace_malloc.c:660)
==10732==    by 0x3EB8805F1C: av_malloc (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB7DC0526: h263_encode_init (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7CF6B4A: MPV_encode_init (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7C911EF: avcodec_open (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x40B44D: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x3D1721D8B3: (below main) (in /lib64/libc-2.5.so)
==10732==
==10732== 1,432 bytes in 1 blocks are possibly lost in loss record 63 of 123
==10732==    at 0x4A05016: memalign (vg_replace_malloc.c:532)
==10732==    by 0x4A0506F: posix_memalign (vg_replace_malloc.c:660)
==10732==    by 0x3EB8805F1C: av_malloc (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB8805FB4: av_mallocz (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB7CD962C: ff_alloc_picture (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7CD9B98: MPV_frame_start (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7DB2B26: ff_h263_decode_frame (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7C905B7: avcodec_decode_video2 (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x4094C2: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x40C18C: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x3D1721D8B3: (below main) (in /lib64/libc-2.5.so)
==10732==
==10732== 3,432 bytes in 1 blocks are definitely lost in loss record 81 of
123
==10732==    at 0x4A05016: memalign (vg_replace_malloc.c:532)
==10732==    by 0x4A0506F: posix_memalign (vg_replace_malloc.c:660)
==10732==    by 0x3EB8805F1C: av_malloc (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB8805FB4: av_mallocz (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB7C919FD: avcodec_default_get_buffer (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7CD94B8: ff_alloc_picture (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7CD9B98: MPV_frame_start (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7DB2B26: ff_h263_decode_frame (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7C905B7: avcodec_decode_video2 (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x4094C2: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x40C18C: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x3D1721D8B3: (below main) (in /lib64/libc-2.5.so)
==10732==
==10732== 3,432 bytes in 1 blocks are definitely lost in loss record 82 of
123
==10732==    at 0x4A05016: memalign (vg_replace_malloc.c:532)
==10732==    by 0x4A0506F: posix_memalign (vg_replace_malloc.c:660)
==10732==    by 0x3EB8805F1C: av_malloc (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB8805FB4: av_mallocz (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB7C919FD: avcodec_default_get_buffer (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7CD94B8: ff_alloc_picture (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7CF7FF5: MPV_encode_picture (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7C91EBE: avcodec_encode_video (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x408143: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x40C18C: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x3D1721D8B3: (below main) (in /lib64/libc-2.5.so)
==10732==
==10732== 9,872 bytes in 2 blocks are possibly lost in loss record 93 of 123
==10732==    at 0x4A05016: memalign (vg_replace_malloc.c:532)
==10732==    by 0x4A0506F: posix_memalign (vg_replace_malloc.c:660)
==10732==    by 0x3EB8805F1C: av_malloc (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB8805FB4: av_mallocz (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB7CD99BF: ff_alloc_picture (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7CD9B98: MPV_frame_start (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7DB2B26: ff_h263_decode_frame (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x3EB7C905B7: avcodec_decode_video2 (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x4094C2: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x40C18C: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x3D1721D8B3: (below main) (in /lib64/libc-2.5.so)
==10732==
==10732== 243,574 (16,648 direct, 226,926 indirect) bytes in 1 blocks are
definitely lost in loss record 120 of 123
==10732==    at 0x4A05016: memalign (vg_replace_malloc.c:532)
==10732==    by 0x4A0506F: posix_memalign (vg_replace_malloc.c:660)
==10732==    by 0x3EB8805F1C: av_malloc (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB8805FB4: av_mallocz (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB7C91166: avcodec_open (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x40C59E: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x3D1721D8B3: (below main) (in /lib64/libc-2.5.so)
==10732==
==10732== 786,432 bytes in 1 blocks are possibly lost in loss record 122 of
123
==10732==    at 0x4A05E1C: malloc (vg_replace_malloc.c:195)
==10732==    by 0x4A05E96: realloc (vg_replace_malloc.c:476)
==10732==    by 0x3EB784E13B: ??? (in /usr/lib/libavformat.so.52.37.0)
==10732==    by 0x3EB781E7B4: av_interleaved_write_frame (in
/usr/lib/libavformat.so.52.37.0)
==10732==    by 0x40585D: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x4081EB: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x40C18C: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x3D1721D8B3: (below main) (in /lib64/libc-2.5.so)
==10732==
==10732== 897,764 (16,648 direct, 881,116 indirect) bytes in 1 blocks are
definitely lost in loss record 123 of 123
==10732==    at 0x4A05016: memalign (vg_replace_malloc.c:532)
==10732==    by 0x4A0506F: posix_memalign (vg_replace_malloc.c:660)
==10732==    by 0x3EB8805F1C: av_malloc (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB8805FB4: av_mallocz (in /usr/lib/libavutil.so.50.3.0)
==10732==    by 0x3EB7C91166: avcodec_open (in
/usr/lib/libavcodec.so.52.32.0)
==10732==    by 0x40B44D: ??? (in /usr/bin/ffmpeg)
==10732==    by 0x3D1721D8B3: (below main) (in /lib64/libc-2.5.so)
==10732==
==10732== LEAK SUMMARY:
==10732==    definitely lost: 41,496 bytes in 7 blocks
==10732==    indirectly lost: 1,108,199 bytes in 157 blocks
==10732==      possibly lost: 797,736 bytes in 4 blocks
==10732==    still reachable: 608,875 bytes in 15 blocks
==10732==         suppressed: 0 bytes in 0 blocks
==10732== Reachable blocks (those to which a pointer was found) are not
shown.
==10732== To see them, rerun with: --leak-check=full --show-reachable=yes
==10732==
==10732== For counts of detected and suppressed errors, rerun with: -v
==10732== ERROR SUMMARY: 10 errors from 10 contexts (suppressed: 4 from 4)



More information about the ffmpeg-devel mailing list