[Ffmpeg-devel] Potential memory leak when using libavcodec.so

Michael Niedermayer michaelni
Fri Aug 12 10:56:42 CEST 2005


Hi

On Wed, Aug 10, 2005 at 02:56:41PM +0000, Burkhard Plaum wrote:
> One issue, I addressed some time ago....
> 
> The problem when using a shared libavcodec, is that the right time for calling
> av_free_static() cannot always be determined. Reference counting doesn't 
> work, because an application, which uses e.g. libquicktime, doesn't even know, 
> if libavcodec is used or not (and it doesn't NEED to know it, that the nice
> thing when using plugins). Putting av_free_static() into libquicktime
> also doesn't work, because we never know, if lavc is used somewhere else in the
> process (e.g. a transcoding application which uses lavc for en- and decoding).
> 
> For elf targets, there is a reliable, simple and completely harmless solution 
> by putting a function into the fini section of the object file (by using 
> __attribute__ ((destructor)) ). This function will always be called at the 
> right time before lavc gets unloaded. Probably it also works for other targets 
> than elf. I tested it for a long time, it never caused problems and valgrind 
> reports 0 lost bytes. Would you accept such a patch?

yes, if someone maintains it (=fix related bugs within less then a week or
show some sign of actively working on it at least)
it also must not break existing code which explicitly calls av_free_static()

[...]
-- 
Michael





More information about the ffmpeg-devel mailing list