[Libav-user] Memory leak using AVStream

David Nguyen david2456 at gmail.com
Fri Jul 15 08:49:26 CEST 2016


Hi,

I am upgrading from FFmpeg 2.8.4 to 3.1.1, and changing code to not use
AVStream.codec anymore. By doing so, I get a memory leak with valgrind,
here's the trace

==15481==    at 0x4A07306: memalign (vg_replace_malloc.c:532)
==15481==    by 0x4A0735F: posix_memalign (vg_replace_malloc.c:660)
==15481==    by 0x6EA3E48: av_malloc (mem.c:97)
==15481==    by 0x6EA4165: av_mallocz (mem.c:254)
==15481==    by 0x599D3E8: init_context_defaults (options.c:127)
==15481==    by 0x599D540: avcodec_alloc_context3 (options.c:163)
==15481==    by 0x6BDED26: avformat_new_stream (utils.c:4098)

Seems like AVCodecContext.priv_data is not being freed.

Looking at the code, the AVStream.codec is still being allocated by you and
freed here
https://www.ffmpeg.org/doxygen/3.1/libavformat_2utils_8c_source.html at
line 3980.

Because I am experiencing a leak, shouldn't that line be
avcodec_free_context(&st->codec) or avcodec_close(st->codec) as it is an
AVCodecContext ?

I used to close st->codec myself before this deprecation.
What am I missing here?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160715/9888624d/attachment.html>


More information about the Libav-user mailing list