[x264-devel] Delete the huge memory leak in x264.

Loren Merritt lorenm at u.washington.edu
Mon Nov 26 12:52:30 CET 2007


On Mon, 26 Nov 2007, alexander tian wrote:

> I found huge memory leak in the x264. There are at least 3 positions which
> has memory leak. Such as below:
>
> 1. The function "x264_mb_analyse_load_costs" in file "analyse.c". Here only
> "malloc" the buffer for the parameter "*p_cost_mv[52]". But not free them in
> the end. It should be freed at the function "x264_encoder_close".

This is intentional. p_cost_mv is shared across all instances of x264. I 
would have made it static const instead of malloced, but then I'd have to 
write the big table literally in the source code. I could still make it 
static non-const, but that wouldn't free any memory, it would just 
appease your leak detector.

> 2. The parameter "i_refs" in the function "x264_macroblock_cache_end" should
> be computed like in the "x264_macroblock_cache_init". Otherwise it will
> cause memory leak.

Fixed, but no I don't have to duplicate the computation.

> 3. Not all the new "x264_frame_t" are deleted at the end of encoding. So it
> cause huge memory leak.

This has been reported before. My reason for not accepting the patch was 
that it conflicts with my experimental alternate threading scheme.

--Loren Merritt



More information about the x264-devel mailing list