[FFmpeg-devel] Memory leak: av_interleaved_write_frame
Thu Jun 24 21:35:29 CEST 2010
Not sure what is wrong and not sure if anybody cares. I started to get lots of leaks from av_interleaved_write_frame and filled out a bug report with a possible fix that I did to avoid the leaks. It appears that current avformat still has the problem.
Here's the reported problem (sorry for typos) https://roundup.ffmpeg.org/msg10665
What's the correct way to close output file??! Every time there is something new added there are new leaks, couldn't there be some api that takes care of all that? At some point I had to add av_metadata_free and I have no idea what metadata and why I needed to free it. Allocated by internal functions and suddenly I need to free it myself. I never did that, but suddenly after some internal changes these structures became allocated internally and I needed to clean them up (Ffmpeg.c had that change made long time by the way : svn.16457 : free all allocated metadata structures).
To fix leaks caused by av_interleaved_write_frame (which dups packets internally)
I had to copy from avformat/utils.c this static function into my code:
/* XXX: suppress the packet queue */
static void flush_packet_queue(AVFormatContext *s)
I already have this to close output file, is there some extra 20-30 call that I'm missing? :) I use ffmpeg.c as a reference, do I also need to close all that chapters and all that stuff unrelated to what I do?
video_ctx = 0;
audio_ctx = 0;
video_stream = 0;
audio_stream = 0;
flush_packet_queue(output_ctx); // <<< ------- copied from avformat/utils.c
output_ctx = 0;
More information about the ffmpeg-devel