[Ffmpeg-devel] Re: Memory leak in output_example ... ?

Mat heavensdoor78
Thu Sep 22 16:29:41 CEST 2005


Burkhard Plaum wrote:

>>==10241== 65552 bytes in 2 blocks are still reachable in loss record 2 of 2
>>==10241==    at 0x1B905141: memalign (vg_replace_malloc.c:216)
>>==10241==    by 0x80A8BAE: av_malloc (mem.c:62)
>>==10241==    by 0x80A6F56: av_mallocz (utils.c:63)
>>==10241==    by 0x80B498B: MPV_encode_defaults (mpegvideo.c:596)
>>==10241==    by 0x80AA939: MPV_encode_init (mpegvideo.c:893)
>>==10241==    by 0x81C485F: encode_init (mpeg12.c:224)
>>==10241==    by 0x80A7663: avcodec_open (utils.c:832)
>>==10241==    by 0x80546A0: open_video (output_example.c:262)
>>==10241==    by 0x8054EB1: main (output_example.c:465)
>>    
>>
>If the av_mallocz() in mpegvideo.c:596 is replaced by av_mallocz_static(),
>this leak should go away (it's one of those leaks, which are harmless for static
>linking but serious in shared libs). Not sure about the other one.
>
Good, you have found the first memory leak of 4 :)
Thank you Burkhard !

In mpegvideo.c this was the only av_mallocz the others are 
av_mallocz_static.
In the same file I see 7 av_malloc ... mmm. Can you help me more ??? :)

 From CVS 2005-09-19.
Now valgrind says:

==8897== Memcheck, a memory error detector for x86-linux.
==8897== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==8897== Using valgrind-2.4.0, a program supervision framework for 
x86-linux.
==8897== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==8897==
==8897== My PID = 8897, parent PID = 3259.  Prog and args are:
==8897==    ./output_example
==8897==    test.vob
==8897== For more details, rerun with: -v
==8897==
==8897==
==8897== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 17 from 1)
==8897== malloc/free: in use at exit: 34208 bytes in 3 blocks.
==8897== malloc/free: 476 allocs, 473 frees, 2163416 bytes allocated.
==8897== For counts of detected errors, rerun with: -v
==8897== searching for pointers to 3 not-freed blocks.
==8897== checked 524296 bytes.
==8897==
==8897== 1432 bytes in 2 blocks are definitely lost in loss record 1 of 2
==8897==    at 0x1B905141: memalign (vg_replace_malloc.c:216)
==8897==    by 0x80A8AEE: av_malloc (mem.c:62)
==8897==    by 0x80A82C4: avcodec_alloc_context (utils.c:767)
==8897==    by 0x80599A1: av_new_stream (utils.c:2179)
==8897==    by 0x805453C: add_video_stream (output_example.c:187)
==8897==    by 0x80552CE: main (output_example.c:447)
==8897==
==8897==
==8897== 32776 bytes in 1 blocks are still reachable in loss record 2 of 2
==8897==    at 0x1B905141: memalign (vg_replace_malloc.c:216)
==8897==    by 0x80A8AEE: av_malloc (mem.c:62)
==8897==    by 0x80A6E96: av_mallocz (utils.c:63)
==8897==    by 0x81C2A10: ff_mpeg1_encode_init (mpeg12.c:800)
==8897==    by 0x80AB074: MPV_encode_init (mpegvideo.c:1276)
==8897==    by 0x81C466F: encode_init (mpeg12.c:224)
==8897==    by 0x80A75A3: avcodec_open (utils.c:831)
==8897==    by 0x80546A0: open_video (output_example.c:262)
==8897==    by 0x8054EB1: main (output_example.c:465)
==8897==
==8897== LEAK SUMMARY:
==8897==    definitely lost: 1432 bytes in 2 blocks.
==8897==      possibly lost: 0 bytes in 0 blocks.
==8897==    still reachable: 32776 bytes in 1 blocks.
==8897==         suppressed: 0 bytes in 0 blocks.





More information about the ffmpeg-devel mailing list