<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello Daniel,<br>
<br>
Daniel-Constantin Mierla schrieb:
<blockquote cite="mid:4A2E279F.8090007@gmail.com" type="cite">Do you
call pv_parse_ht_name() from perl? If not, that function is executed
only at startup and it is not a cause for leaking. A clean shutdown
should free it, but there is not complete support for it (some fixup
functions have a free function, others done, as well as the script
actions tree).
<br>
</blockquote>
We're not calling this directly from perl, but it seems it is called
automatically every time when accessing the pv $sht. We've modified
ht_var.c from module htable for getting a backtrace every time memory
is allocated in pv_parse_ht_name:<br>
<br>
<blockquote><small>void printBacktrace()<br>
{<br>
void *array[100];<br>
size_t size;<br>
char **strings;<br>
size_t i;<br>
<br>
size = backtrace (array, 100);<br>
strings = backtrace_symbols (array, size);<br>
<br>
LM_DBG("Obtained %zd stack frames.\n", size);<br>
<br>
for (i = 0; i < size; i++)<br>
LM_DBG("%s\n", strings[i]);<br>
<br>
free (strings);<br>
}<br>
<br>
int pv_parse_ht_name(pv_spec_p sp, str *in)<br>
{<br>
ht_pv_t *hpv=NULL;<br>
char *p;<br>
str pvs;<br>
<br>
if(in->s==NULL || in->len<=0)<br>
return -1;<br>
<br>
hpv = (ht_pv_t*)pkg_malloc(sizeof(ht_pv_t));<br>
if(hpv==NULL)<br>
return -1;<br>
<br>
LM_DBG("Allocated new memory %u/0x%x in pv_parse_ht_name()",
hpv, hpv);<br>
printBacktrace();<br>
[...]<br>
</small></blockquote>
When making a call we get the following outputs:<br>
<br>
xlog:<br>
<br>
<blockquote><small>May 29 16:56:01 AmbriaSip1
/usr/local/sbin/kamailio[27187]: DBG:htable:pv_parse_ht_name: Allocated
new memory 136020048 in pv_parse_ht_name()<br>
May 29 16:56:01 AmbriaSip1 /usr/local/sbin/kamailio[27187]:
DBG:htable:printBacktrace: Obtained 10 stack frames. <br>
May 29 16:56:01 AmbriaSip1 /usr/local/sbin/kamailio[27187]:
DBG:htable:printBacktrace:
/usr/local/lib/kamailio/modules/htable.so(printBacktrace+0x2d)
[0x1dd1c5] <br>
May 29 16:56:01 AmbriaSip1 /usr/local/sbin/kamailio[27187]:
DBG:htable:printBacktrace:
/usr/local/lib/kamailio/modules/htable.so(pv_parse_ht_name+0x8f)
[0x1dd8fe] <br>
May 29 16:56:01 AmbriaSip1 /usr/local/sbin/kamailio[27187]:
DBG:htable:printBacktrace:
/usr/local/sbin/kamailio(pv_parse_spec+0x58f) [0x8082c35] <br>
May 29 16:56:01 AmbriaSip1 /usr/local/sbin/kamailio[27187]:
DBG:htable:printBacktrace:
/usr/local/sbin/kamailio(pv_parse_format+0x1eb) [0x808409e] <br>
May 29 16:56:01 AmbriaSip1 /usr/local/sbin/kamailio[27187]:
DBG:htable:printBacktrace: /usr/local/lib/kamailio/modules/xlog.so
[0x1482c6] <br>
May 29 16:56:01 AmbriaSip1 /usr/local/sbin/kamailio[27187]:
DBG:htable:printBacktrace: /usr/local/lib/kamailio/modules/xlog.so
[0x148620] <br>
May 29 16:56:01 AmbriaSip1 /usr/local/sbin/kamailio[27187]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio [0x808e68e] <br>
May 29 16:56:01 AmbriaSip1 /usr/local/sbin/kamailio[27187]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio(fix_rls+0x12b)
[0x8096892] <br>
May 29 16:56:01 AmbriaSip1 /usr/local/sbin/kamailio[27187]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio(main+0xcd)
[0x8068215] <br>
May 29 16:56:01 AmbriaSip1 /usr/local/sbin/kamailio[27187]:
DBG:htable:printBacktrace: /lib/tls/libc.so.6(__libc_start_main+0xd3)
[0xb51df3] <br>
</small></blockquote>
<br>
and perl:<br>
<br>
<blockquote><small>Jun 2 10:53:28 AmbriaSip1
/usr/local/sbin/kamailio[19777]: DBG:htable:pv_parse_ht_name: Allocated
new memory 136017028/0x81b7484 in pv_parse_ht_name()</small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace: Obtained 27 stack frames. </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/lib/kamailio/modules/htable.so(printBacktrace+0x33)
[0xf631cb] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/lib/kamailio/modules/htable.so(pv_parse_ht_name+0x8f)
[0xf63a42] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/sbin/kamailio(pv_parse_spec+0x58f) [0x8082c35] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/sbin/kamailio(pv_parse_format+0x1eb) [0x808409e] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/lib/kamailio/modules/perl.so(pv_sprintf+0x93) [0x2a40c8] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/lib/kamailio/modules/perl.so(XS_OpenSER__Message_pseudoVar+0x17f)
[0x2a92f3] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE/libperl.so(Perl_pp_entersub+0x2ea)
[0x813c</small><br>
<small>b2] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE/libperl.so(Perl_runops_debug+0xba)
[0x7f71</small><br>
<small>6d] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE/libperl.so [0x7a1b26]
</small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE/libperl.so(Perl_call_sv+0x6d7)
[0x7a7ef1] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE/libperl.so(Perl_call_pv+0x40)
[0x7a81f9] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/lib/kamailio/modules/perl.so(perl_exec2+0x198) [0x2af1c4] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/lib/kamailio/modules/perl.so(perl_exec1+0x2c) [0x2af69d] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio(do_action+0x1401)
[0x80531ed] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/sbin/kamailio(run_action_list+0x28) [0x8055406] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio(do_action+0x20ed)
[0x8053ed9] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/sbin/kamailio(run_action_list+0x28) [0x8055406] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio(do_action+0x3199)
[0x8054f85] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/sbin/kamailio(run_action_list+0x28) [0x8055406] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio(do_action+0x3199)
[0x8054f85] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace:
/usr/local/sbin/kamailio(run_action_list+0x28) [0x8055406] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio(run_top_route+0x6d)
[0x805570e] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio(receive_msg+0x572)
[0x8087934] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio(udp_rcv_loop+0xd26)
[0x80be5a6] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio(main+0x3219)
[0x806b361] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace: /lib/tls/libc.so.6(__libc_start_main+0xd3)
[0xb51df3] </small><br>
<small>Jun 2 10:53:28 AmbriaSip1 /usr/local/sbin/kamailio[19777]:
DBG:htable:printBacktrace: /usr/local/sbin/kamailio [0x8051991] </small><br>
</blockquote>
So because of this we don't think it is just called once but the
allocated memory should be freed after processing a message.<br>
<br>
<br>
<blockquote cite="mid:4A2E279F.8090007@gmail.com" type="cite"><br>
That structure is not freed because it used at runtime. During startup,
the name of $sht is parsed and kept as custom structure to be used
latter, for speed reasons.
<br>
<br>
I tried to access the files you uploaded, with the log, but they
expired. If you have the one with memory debug, please send it to me.
<br>
</blockquote>
We still have it, but its 43MB (already zipped) and it's without the
above "printBacktrace". If you need it anyway or need a complete
logfile including the backtrace we could send it to you.<br>
<br>
Thanks for your help,<br>
Christian<br>
</body>
</html>