<br><br><div class="gmail_quote">On Wed, May 26, 2010 at 8:09 PM, Mark Michelson <span dir="ltr"><<a href="mailto:mmichelson@digium.com">mmichelson@digium.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On 05/26/2010 02:12 AM, MohammedShehzad wrote:<br>
><br>
><br>
> On Wed, May 26, 2010 at 1:11 AM, Mark Michelson wrote:<br>
><br>
> On 05/25/2010 08:18 AM, MohammedShehzad wrote:<br>
> ><br>
> > Hi all,<br>
> ><br>
> > My custom IVR application of asterisk records the voice of user.<br>
> > It sets the read format to sleaner using ast_set_read_format<br>
> funciton<br>
> > on line number 2144.<br>
> > flag = ast_set_read_format(chan, AST_FORMAT_SLINEAR);<br>
> > Which is leaving behind some leaks : below is the part of the<br>
> trace of<br>
> > asterisk under run valgrind as below:<br>
> ><br>
> > ==11972==<br>
> > ==11972== 52,512 bytes in 3 blocks are definitely lost in loss<br>
> record<br>
> > 115 of 117<br>
> > ==11972== at 0x4A04B32: calloc (vg_replace_malloc.c:279)<br>
> > ==11972== by 0x4A601D: newpvt (utils.h:359)<br>
> > ==11972== by 0x4A714F: ast_translator_build_path<br>
> (translate.c:288)<br>
> > ==11972== by 0x438270: set_format (channel.c:2778)<br>
> > ==11972== by 0x162A19A8: ??? (app_custom_ivr.c:2144)<br>
> > ==11972== by 0x1629FB83: ??? (app_custom_ivr.c:1099)<br>
> > ==11972== by 0x1629EB25: ??? (app_custom_ivr.c:525)<br>
> > ==11972== by 0x47F21C: pbx_extension_helper (pbx.c:537)<br>
> > ==11972== by 0x4814E0: __ast_pbx_run (pbx.c:2317)<br>
> > ==11972== by 0x482158: pbx_thread (pbx.c:2634)<br>
> > ==11972== by 0x4AB3EB: dummy_start (utils.c:865)<br>
> > ==11972== by 0x376EC06616: start_thread (in<br>
> > /lib64/<a href="http://libpthread-2.5.so" target="_blank">libpthread-2.5.so</a> <<a href="http://libpthread-2.5.so" target="_blank">http://libpthread-2.5.so</a>><br>
> <<a href="http://libpthread-2.5.so" target="_blank">http://libpthread-2.5.so</a>>)<br>
> > ==11972== by 0x376E4D3C2C: clone (in /lib64/<a href="http://libc-2.5.so" target="_blank">libc-2.5.so</a><br>
> <<a href="http://libc-2.5.so" target="_blank">http://libc-2.5.so</a>><br>
> > <<a href="http://libc-2.5.so" target="_blank">http://libc-2.5.so</a>>)<br>
> > ==11972==<br>
> ><br>
> > I do reset the read format back to old read format, but even<br>
> though it<br>
> > is showing leaks.<br>
> ><br>
> > Any one can please let me know what i am missing in using<br>
> > ast_set_read_format function?<br>
> ><br>
> ><br>
> > --<br>
> ><br>
> > -MohammedShehzad<br>
><br>
> ast_set_read_format will allocate memory if it needs to create a<br>
> translation path. However, when you call ast_set_read_format, the old<br>
> translation path on the channel will be freed first. Furthermore,<br>
> when a<br>
> channel is destroyed, the translation path is freed as well.<br>
><br>
> When are you seeing this output from valgrind? Are you stopping<br>
> Asterisk<br>
> with channels still up? if that is the case, then it is not surprising<br>
> to see that there is still memory allocated for translation paths.<br>
><br>
> Mark Michelson<br>
><br>
> I assume that there is no need to call any function to destroy the<br>
> channel implicitly.<br>
> I get this output after making few calls which hits the custom IVR.<br>
> Although I stop the asterisk only after making sure that no channel is<br>
> active.<br>
><br>
> --<br>
><br>
> -MohammedShehzad<br>
<br>
</div></div>Even though no channels may be active, you may have introduced a channel<br>
reference leak in your code (assuming you are using Asterisk trunk<br>
here). If you ever call a function like ast_channel_get_*, then you need<br>
to make sure to call ast_channel_unref on that channel once you are<br>
finished with it. If you issue the CLI command "core show channels"<br>
after all channels are inactive and still see channels listed, this may<br>
be your problem.<br>
<div><div></div><div class="h5"><br>
Mark Michelson<br>
<br clear="all"></div></div></blockquote></div><br>ast_channel_get_* function is not used. Also there is no channel present in "core show channels", after not showing in cli i am stopping asterisk then also it is showing memory leak.<br>
-- <br><br>-MohammedShehzad<br>