[FFmpeg-user] ffmpeg threads not deleted after closing streams, resulting in mem-leak
bjoern.drabeck at gmail.com
Fri Jun 1 11:08:07 CEST 2012
> I am having a problem where every time I play a movie in the app I am
> writing (using ffmpeg LGPL), after closing a file it seems like it is
> leaking a lot of memory.
> Recently I have mostly developed on Mac OS X 10.7 and every time I close a
> video file and then open another one, it seems to leak quite a lot of
> memory. The more threads I use, the more severe the problem is, if I set
> codecContext->thread_count to 1 it is the least (but that doesn't give good
> enough results for HD movies).
> Also if I stop execution with the debugger, it seems every time after
> closing a file, there are some "leftover threads" from ffmpeg (which I
> assume might hold the memory that is leaking). In my current setup with a
> 1920x1080 HD file I am left with 5 threads and about 50 MB of leaked memory
> every time I play a movie. (I didn't seem to have that issue before when I
> used ffmpeg 0.9 and single thread)
> So I am wondering if with recent changes there is something that I am not
> doing correctly, or if this is really a known bug in ffmpeg?
> My flow is (roughly) like this:
> - avformat_open_input()
> - then I pick the streams that I want to use, find a decoder
> avcodec_find_decoder() and open it avcodec_open2
> - I read the file with av_read_frame and put the packets into their
> respective decoders, and av_free_packet them afterwards
> - once I am finished I call avcodec_close for all the opened codec and
> finally avformat_close_input
> I make sure all the packets, and all the objects I created along the way
> (swresampler, swscaler, various AVFrame objects etc) are deleted prior to
> calling the close functions.
> But is there something I need to do to ensure the threads that are created
> inside ffmpeg are terminated and all the memory they allocated is removed?
Does anyone else happen to know what's going on here or what I am doing
More information about the ffmpeg-user