[x264-devel] [PATCH] Fixed: large memory-leaks when the encoder is closed.

Boris Nagels develop at focusware.nl
Wed Jan 3 23:22:56 CET 2018


Some more info: I didn’t use the x264 library directly, instead the calls are made from the within the ffmpeg library that I’m using (x264 encoder part).
Probably the leak occurs because of a combination of the 2 libraries. I’ll look in more detail at the series of calls when the memory leaks occur.

The leaks were reported by the “leak instrument” that is part of Xcode.

> On 3 Jan 2018, at 00:26, Henrik Gramner <henrik at gramner.com> wrote:
> 
> On Tue, Jan 2, 2018 at 11:31 PM, Boris Nagels <develop at focusware.nl> wrote:
>> Calling x264_encoder_close() will also call x264_analyse_free_costs() to free up the allocated resources. The current implementation checks the wrong pointers if they're valid. This is because the pointers that are stored in the x264_t structure are shifted (see implementation for x264_analyse_init_costs()). This patch also stores the original pointers that were allocated, to be able to free the memory when the codec is closed. In the original implementation, this leads to memory-leaks and/or memory corruption when the encoder is opened/closed and reopened.
> 
> The pointers should only be wrong if h->param.analyse.i_mv_range
> changes between encoder_open() and encoder_close() and I don't believe
> mv-range can be reconfigured after the encoder has been opened.
> 
> valgrind does not indicate any errors or memory leaks for me.
> _______________________________________________
> x264-devel mailing list
> x264-devel at videolan.org
> https://mailman.videolan.org/listinfo/x264-devel



More information about the x264-devel mailing list