<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <tt>Hi, Federico!<br>
      <br>
      Nice catch! Indeed, there seems to be a pkg memory leak during
      reload.<br>
      I committed a fix on the master branch that shoul fix this
      issue[1]. Can you pelase test and let me know everything is ok
      this time, so I can backport the fix to the other branches (2.1,
      1.11).<br>
      <br>
      [1]
<a class="moz-txt-link-freetext" href="https://github.com/OpenSIPS/opensips/commit/aa7429e0124478f999ba3737b10ae39900e16b2c">https://github.com/OpenSIPS/opensips/commit/aa7429e0124478f999ba3737b10ae39900e16b2c</a><br>
      <br>
      Thanks,<br>
    </tt>
    <pre class="moz-signature" cols="72">Răzvan Crainea
OpenSIPS Solutions
<a class="moz-txt-link-abbreviated" href="http://www.opensips-solutions.com">www.opensips-solutions.com</a></pre>
    <div class="moz-cite-prefix">On 09/11/2015 05:07 PM, Federico Edorna
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAKi1vHh6EGQTe-pRa03Dn234iFRWQKSzfF4mG+knm5XBoW-ajQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hello,
        <div> 
          <div>in function load_pcres in regex_mod.c, I see that when
            you allocate memory to read regex groups, the loop goes up
            to the max_groups parameter (<a moz-do-not-send="true"
href="http://www.opensips.org/html/docs/modules/1.11.x/regex.html#id249240"
              target="_blank">http://www.opensips.org/html/docs/modules/1.11.x/regex.html#id249240</a>)
            :</div>
          <div><br>
          </div>
          <div>
            <div>for (i=0; i&lt;max_groups; i++) {</div>
            <div>                if ((patterns[i] =
              pkg_malloc(sizeof(char) * group_max_size)) == 0) {</div>
            <div>                        LM_ERR("no more memory for
              patterns[%d]\n", i);</div>
            <div>                        fclose(f);</div>
            <div>                        goto err;</div>
            <div>                }</div>
            <div>                memset(patterns[i], '\0',
              group_max_size);</div>
            <div>        }</div>
          </div>
          <div><br>
          </div>
          <div>but when you free memory, it seems that it's only done
            for the patterns that actually are being used.</div>
          <div><br>
          </div>
          <div>In fact, if I set the max_groups parameter to the same
            amount of patterns in the regex file:</div>
          <div><br>
          </div>
          <div>modparam("regex", "max_groups", 4)<br>
          </div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra">when I run the "fifo regex_reload"
            loop, I never run out of pkmemory.</div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra">Regards<br clear="all">
            <div>
              <div>
                <div dir="ltr"><br>
                </div>
              </div>
            </div>
            <br>
            <div class="gmail_quote">On Fri, Sep 4, 2015 at 12:18 PM,
              Federico Edorna <span dir="ltr">&lt;<a
                  moz-do-not-send="true"
                  href="mailto:fedorna@anura.com.ar" target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:fedorna@anura.com.ar">fedorna@anura.com.ar</a></a>&gt;</span>
              wrote:<br>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                <div dir="ltr">Hi Team, I've found an issue when I
                  reload regular expresion file for opensips 1.11.5.
                  <div><br>
                  </div>
                  <div>After executing a few "opensipsctl fifo
                    regex_reload", the fifo process runs out of pkmem.
                    This is a small loop where I do a regex_reload and
                    then I print the pkmem for MI FIFO processs:</div>
                  <div><br>
                  </div>
                  <div>
                    <div>root@toro:~# sudo -u gc
                      /home/gc/local/opensips/sbin/opensipsctl fifo ps |
                      grep "ID=4 "</div>
                    <div>Process::  ID=4 PID=11040 Type=MI FIFO</div>
                    <div>root@toro:~# while [ 1 -eq 1 ] ; do sudo -u gc
                      /home/gc/local/opensips/sbin/opensipsctl fifo
                      regex_reload; sudo -u gc
                      /home/gc/local/opensips/sbin/opensipsctl fifo
                      get_statistics pkmem: |grep "pkmem:4-free_size::"
                       ; done</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 3353184</div>
                    <div>pkmem:4-free_size:: 1466776</div>
                    <div>pkmem:4-free_size:: 1466776</div>
                    <div>pkmem:4-free_size:: 1466776</div>
                    <div>pkmem:4-free_size:: 1466776</div>
                    <div>pkmem:4-free_size:: 1466776</div>
                    <div>pkmem:4-free_size:: 1466776</div>
                    <div>pkmem:4-free_size:: 1466776</div>
                    <div>pkmem:4-free_size:: 1466776</div>
                    <div>pkmem:4-free_size:: 1466776</div>
                    <div>pkmem:4-free_size:: 1466776</div>
                    <div>pkmem:4-free_size:: 140696</div>
                    <div>500 Server Internal Error</div>
                    <div>pkmem:4-free_size:: 140696</div>
                    <div>500 Server Internal Error</div>
                    <div>pkmem:4-free_size:: 140696</div>
                    <div>500 Server Internal Error</div>
                    <div>pkmem:4-free_size:: 140696</div>
                    <div>500 Server Internal Error</div>
                    <div>^C</div>
                    <div>root@toro:~#</div>
                    <div><br>
                    </div>
                    <div>For the following regex_reload commands the
                      error in the syslog file is this :</div>
                    <div><br>
                    </div>
                    <div>
                      <div>2015-09-04T11:56:05.645485-03:00 toro
                        /home/gc/local/opensips/sbin/opensips[11040]:
                        ERROR:regex:load_pcres: no more memory for
                        patterns[11]</div>
                      <div>2015-09-04T11:56:05.645567-03:00 toro
                        /home/gc/local/opensips/sbin/opensips[11040]:
                        ERROR:regex:mi_pcres_reload: failed to reload
                        pcres</div>
                    </div>
                    <div><br>
                    </div>
                    <div>The only way to recover from this is to restart
                      opensips.</div>
                    <div><br>
                    </div>
                    <div>I've pasted the syslog (compiled with
                      DBG_QM_MALLOC option) when the command is
                      succesfull: <a moz-do-not-send="true"
                        href="http://pastebin.com/VnMZrYrh"
                        target="_blank">http://pastebin.com/VnMZrYrh</a></div>
                  </div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <div>I tyied to increase the pkmem for the process,
                    but sooner or later the error came up</div>
                  <div><br>
                  </div>
                  <div>Thanks in advance!</div>
                  <span><font color="#888888">
                      <div>Federico</div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                    </font></span></div>
              </blockquote>
            </div>
            <br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>