<div dir="ltr"><div style="font-size:12.8px"><div><div><div><div><div><div><div>Hi,<br></div><br></div>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<br><br>==15481==    at 0x4A07306: memalign (vg_replace_malloc.c:532)<br>==15481==    by 0x4A0735F: posix_memalign (vg_replace_malloc.c:660)<br>==15481==    by 0x6EA3E48: av_malloc (mem.c:97)<br>==15481==    by 0x6EA4165: av_mallocz (mem.c:254)<br>==15481==    by 0x599D3E8: init_context_defaults (options.c:127)<br>==15481==    by 0x599D540: avcodec_alloc_context3 (options.c:163)<br>==15481==    by 0x6BDED26: avformat_new_stream (utils.c:4098)<br><br></div><div>Seems like AVCodecContext.priv_data is not being freed.<br><br></div>Looking at the code, the AVStream.codec is still being allocated by you and freed here<br><a href="https://www.ffmpeg.org/doxygen/3.1/libavformat_2utils_8c_source.html" target="_blank">https://www.ffmpeg.org/doxygen/3.1/libavformat_2utils_8c_source.html</a> at line 3980.<br></div><br></div>Because I am experiencing a leak, shouldn't that line be <br>avcodec_free_context(&st->codec) or avcodec_close(st->codec) as it is an AVCodecContext ?<br></div><div><br>I used to close st->codec myself before this deprecation.<br></div>What am I missing here?<br><br></div>Thanks,<br><br></div><span style="font-size:12.8px">David</span><br></div>