[FFmpeg-devel] Memory leaks using x265 encoder

Oliver Collyer ovcollyer at mac.com
Wed Jan 2 17:32:56 EET 2019

>>> +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.

Although....the data that x265_cleanup() frees is static anyway (see Bitcost::Destroy()), so I think this is actually desired behaviour i.e. this is global state across all APIs that should be freed up before exit.

Can you clarify what you mean by "static variables are unacceptable". They're all over the place in ffmpeg (random example https://github.com/FFmpeg/FFmpeg/blob/a0ac49e38ee1d1011c394d7be67d0f08b2281526/libavcodec/ffjni.c <https://github.com/FFmpeg/FFmpeg/blob/a0ac49e38ee1d1011c394d7be67d0f08b2281526/libavcodec/ffjni.c>)... what am I missing?



More information about the ffmpeg-devel mailing list