[FFmpeg-devel] Memory leaks using x265 encoder

Oliver Collyer ovcollyer at mac.com
Wed Jan 2 17:18:29 EET 2019



> On 2 Jan 2019, at 18:05, Nicolas George <george at nsup.org> wrote:
> 
> Oliver Collyer (2019-01-02):
>> diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
> 
> Please use git format-patch to prepare your patches. Also please try to
> convince your MUA to use text/plain for patches.
> 
>> +static int open_enc_count = 0;
>> +static pthread_mutex_t open_enc_count_lock = PTHREAD_MUTEX_INITIALIZER;
> 
> Static variables are unacceptable. And indeed, these are wrong: you are
> counting several instances, possibly of different APIs, but with a
> single counter.
> 

Yes, I see what you mean.

> The way I read things, the leak you are trying to fix does not exist: it
> is global state, kept until the end but not lost.
> 

Well, as per my earlier post - x265 provides a function to free up this memory which otherwise isn't freed up, hence memory debuggers report these allocations as leaks, and ffmpeg provides no mechanism to call this function.

I guess the OS frees it up on application exit, but that seems a messy way to be going about things, I guess that's why the developers of x265 provided the function.

> Regards,
> 
> -- 
>  Nicolas George
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



More information about the ffmpeg-devel mailing list