I found a memory leak in x264_mb_analyse_load_costs. It keeps some x264_malloc&#39;ed pointer to a global array, but no one remembers to free them in x264_encoder_close.<br><br> 184     if( !p_cost_mv[a-&gt;i_qp] )<br> 185     {<br>
 186         x264_emms();<br> 187         /* could be faster, but isn&#39;t called many times */<br> 188         /* factor of 4 from qpel, 2 from sign, and 2 because mv can be opposite from mvp */<br> 189         p_cost_mv[a-&gt;i_qp] = x264_malloc( (4*4*2048 + 1) * sizeof(int16_t) );<br>
 190         p_cost_mv[a-&gt;i_qp] += 2*4*2048;<br> 191         for( i = 0; i &lt;= 2*4*2048; i++ )<br><br>and<br><br> 207         for( j=0; j&lt;4; j++ )<br> 208         {<br> 209             x264_cost_mv_fpel[a-&gt;i_qp][j] = x264_malloc( (4*2048 + 1) * sizeof(int16_t) );<br>
 210             x264_cost_mv_fpel[a-&gt;i_qp][j] += 2*2048;<br> 211             for( i = -2*2048; i &lt; 2*2048; i++ )<br> 212                 x264_cost_mv_fpel[a-&gt;i_qp][j][i] = p_cost_mv[a-&gt;i_qp][i*4+j];<br> 213         }<br>
<br>valgrind reported:<br><br>==54848== 917,532 bytes in 14 blocks are possibly lost in loss record 10 of 10<br>==54848==    at 0xA61D63: malloc (vg_replace_malloc.c:192)<br>==54848==    by 0x403B24: x264_mb_analyse_load_costs (in /usr/local/bin/ffmpeg)<br>
==54848==    by 0x3FF87D2D: ???<br><br>Regards,<br>jh<br>