[x264-devel] libx264 memory leak

191919 191919 at gmail.com
Tue Mar 3 10:32:50 CET 2009


I found a memory leak in x264_mb_analyse_load_costs. It keeps some
x264_malloc'ed pointer to a global array, but no one remembers to free them
in x264_encoder_close.

 184     if( !p_cost_mv[a->i_qp] )
 185     {
 186         x264_emms();
 187         /* could be faster, but isn't called many times */
 188         /* factor of 4 from qpel, 2 from sign, and 2 because mv can be
opposite from mvp */
 189         p_cost_mv[a->i_qp] = x264_malloc( (4*4*2048 + 1) *
sizeof(int16_t) );
 190         p_cost_mv[a->i_qp] += 2*4*2048;
 191         for( i = 0; i <= 2*4*2048; i++ )

and

 207         for( j=0; j<4; j++ )
 208         {
 209             x264_cost_mv_fpel[a->i_qp][j] = x264_malloc( (4*2048 + 1) *
sizeof(int16_t) );
 210             x264_cost_mv_fpel[a->i_qp][j] += 2*2048;
 211             for( i = -2*2048; i < 2*2048; i++ )
 212                 x264_cost_mv_fpel[a->i_qp][j][i] =
p_cost_mv[a->i_qp][i*4+j];
 213         }

valgrind reported:

==54848== 917,532 bytes in 14 blocks are possibly lost in loss record 10 of
10
==54848==    at 0xA61D63: malloc (vg_replace_malloc.c:192)
==54848==    by 0x403B24: x264_mb_analyse_load_costs (in
/usr/local/bin/ffmpeg)
==54848==    by 0x3FF87D2D: ???

Regards,
jh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20090303/57e8e6f7/attachment.htm>


More information about the x264-devel mailing list