<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.il
        {mso-style-name:il;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal" style="background:white"><span style="color:#222222">Hello<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222">I noticed that I have “live” <span class="il">x264</span> threads despite the fact that ‘x264_encoder_open’ failed (probably due to bad configuration from my side)<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222">While trying to debug it, I found that when ‘x264_encoder_open’ fails, it jumps to ‘fail’ label (goto fail).<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222"> <o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222">‘fail’ do not close any opened threads (encoder and look ahead threads)  and it is simply releasing the allocated memory.<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222"> <o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222">This behaviour was observed on windows (compiled using m-sys and msvc 2015 – see here  : <a href="http://roxlu.com/2016/057/compiling-x264-on-windows-with-msvc" target="_blank"><span style="color:#0563C1">http://roxlu.com/2016/057/compiling-</span><span class="il"><span style="color:#0563C1;text-decoration:none">x264</span></span><span style="color:#0563C1">-on-windows-with-msvc</span></a>),
 but I am pretty sure it’s reproducible on other platforms as well.<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222"> <o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222">The version that appears in x264_config.h file is  " r2901 7d0ff22" (but as far as I can see, it wasn’t fixed in the today’s snapshot)<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222"> <o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222">As a temporary work around I added these few lines before the call x264_free (encoder.c : 1754)<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222"> <o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="font-size:9.5pt;font-family:Consolas;color:black">       </span><span style="font-size:9.5pt;font-family:Consolas;color:blue">if</span><span style="font-size:9.5pt;font-family:Consolas;color:black"> (h->param.i_threads > 1)</span><span style="color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="font-size:9.5pt;font-family:Consolas;color:black">              x264_threadpool_delete(h->threadpool);</span><span style="color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="font-size:9.5pt;font-family:Consolas;color:black"> </span><span style="color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="font-size:9.5pt;font-family:Consolas;color:black">       </span><span style="font-size:9.5pt;font-family:Consolas;color:blue">if</span><span style="font-size:9.5pt;font-family:Consolas;color:black"> (h->param.i_lookahead_threads > 1)</span><span style="color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="font-size:9.5pt;font-family:Consolas;color:black">              x264_threadpool_delete(h->lookaheadpool);</span><span style="color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:36.0pt;background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="font-size:9.5pt;font-family:Consolas;color:black"> </span><span style="color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:36.0pt;background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="font-size:9.5pt;font-family:Consolas;color:black">x264_free( h );</span><span style="color:#222222"><o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222"> <o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222">Appreciate if you can add a proper fix (I guess that my workaround is not complete and there are more objects that needs to be deleted)<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222"> <o:p></o:p></span></p>
<p class="MsoNormal" style="background:white;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">
<span style="color:#222222">Thanks<o:p></o:p></span></p>
<p class="MsoNormal">Koby<o:p></o:p></p>
</div>
</body>
</html>