<h3>Description</h3>

<p>We are using lua base routing with app_lua. We are seeing that our memory-utilization on that system continuously getting increase. our route.lua will have all routing logic same as</p>
<p><a href="https://github.com/kamailio/kamailio/blob/master/misc/examples/kemi/kamailio-basic-kemi-lua.lua">https://github.com/kamailio/kamailio/blob/master/misc/examples/kemi/kamailio-basic-kemi-lua.lua</a></p>
<p>we are using following set of modules<br>
loadmodule "tm.so"<br>
loadmodule "rr.so"<br>
loadmodule "pv.so"<br>
loadmodule "tmx.so"<br>
loadmodule "sl.so"<br>
loadmodule "maxfwd.so"<br>
loadmodule "nathelper.so"<br>
loadmodule "textops.so"<br>
loadmodule "siputils.so"<br>
loadmodule "xlog.so"<br>
loadmodule "sanity.so"<br>
loadmodule "path.so"<br>
loadmodule "jsonrpcs.so"<br>
loadmodule "app_lua.so"<br>
loadmodule "dispatcher.so"<br>
loadmodule "json.so"<br>
loadmodule "cfg_rpc.so"<br>
loadmodule "ctl.so"<br>
loadmodule "ipops.so"<br>
loadmodule "http_async_client.so"<br>
loadmodule "dialog.so"</p>
<h1>----------------- setting module-specific parameters ---------------</h1>
<h1>----- rr params -----</h1>
<h1>set next param to 1 to add value to ;lr param (helps with some UAs)</h1>
<p>modparam("rr", "enable_full_lr", 0)</p>
<h1>do not append from tag to the RR (no need for this script)</h1>
<p>modparam("rr", "append_fromtag", 1)</p>
<h1>----- dispatcher params -----</h1>
<p>modparam("dispatcher", "list_file", DISPATCHER_FILE)<br>
modparam("dispatcher", "ds_probing_mode", 1)<br>
modparam("dispatcher", "flags", 2)<br>
modparam("dispatcher", "ds_ping_interval", 10)<br>
modparam("dispatcher", "ds_ping_from", "sip:<a href="mailto:ping@test.com">ping@test.com</a>")</p>
<h1>----- nathelper params ----</h1>
<p>modparam("nathelper", "received_avp", "$avp(s:rcv)")</p>
<h1>----- http_async_client -------</h1>
<h1>---- number of worker process for async req and res</h1>
<p>modparam("http_async_client", "workers", 4)</p>
<h1>----- ctl ------</h1>
<p>modparam("ctl", "binrpc", "tcp:MY_IP_ADDR:2086")</p>
<h1>----- app_lua params ----</h1>
<p>modparam("app_lua", "reload", 1)<br>
modparam("app_lua", "load", ROUTE_LUA)</p>
<h1>---- dialog params ----</h1>
<p>modparam("dialog", "enable_stats", 1)<br>
modparam("dialog", "dlg_flag", 4)<br>
modparam("dialog", "event_callback", "ksr_dialog_event")</p>
<p>cfgengine "lua"</p>
<h3>Troubleshooting</h3>
<h4>Reproduction</h4>
<p>We can easily reproduce by loading app_lua with kamailio-basic-kemi-lua.lua</p>
<p><a href="https://github.com/kamailio/kamailio/blob/master/misc/examples/kemi/kamailio-basic-kemi-lua.lua">https://github.com/kamailio/kamailio/blob/master/misc/examples/kemi/kamailio-basic-kemi-lua.lua</a></p>

<h4>Debugging Data</h4>
<p>root@ip-172-31-4-160:~# kamcmd -s tcp:172.31.4.160:2046 tm.stats<br>
{<br>
current: 2220<br>
waiting: 2198<br>
total: 6113169<br>
total_local: 1371<br>
rpl_received: 11958486<br>
rpl_generated: 6111711<br>
rpl_sent: 12224635<br>
6xx: 0<br>
5xx: 6104789<br>
4xx: 6831<br>
3xx: 0<br>
2xx: 1483<br>
created: 6113169<br>
freed: 6110949<br>
delayed_free: 0<br>
}</p>
<p>transaction are getting free as they are created so no transaction memory leak.</p>

<pre><code>U 54.183.198.87:5060 -> 172.31.4.160:5060
INVITE sip:919980950111@13.57.122.212:5060 SIP/2.0.
Record-Route: <sip:54.183.198.87;lr;ftag=2186327>.
Via: SIP/2.0/UDP 54.183.198.87:5060;branch=z9hG4bK62f3.22dfb9a43503cc12dafdcdbc9ab1e17d.0.
Via: SIP/2.0/UDP 172.31.13.202:5060;rport=5060;received=13.232.78.75;branch=z9hG4bK-20254-2186327-0.
From: <sip:919980950111@21979254854757081.zt.plivo.com>;tag=2186327.
To: <sip:919980950111@21979254854757081.zt.plivo.com>.
Call-ID: 2186327-20254@172.31.13.202.
CSeq: 1 INVITE.
Contact: <sip:sipp@13.126.252.148:5060;transport=UDP;alias=13.232.78.75~5060~1>.
Max-Forwards: 69.
User-Agent: Sipp/Linux.
Supported: replaces, outbound.
Content-Type: application/sdp.
Content-Length:   139.
X-ZT-Cust-IP: 13.232.78.75.
X-ZT-Trunk: 21979254854757081.zt.plivo.com.
.
v=0.
o=user1 53655765 2353687637 IN IP4 13.126.252.148.
s=-.
c=IN IP4 13.126.252.148.
t=0 0.
m=audio 6000 RTP/AVP 0.
a=rtpmap:0 PCMU/8000.

#
U 172.31.4.160:5060 -> 54.183.198.87:5060
SIP/2.0 100 trying -- your call is important to us.
Via: SIP/2.0/UDP 54.183.198.87:5060;branch=z9hG4bK62f3.22dfb9a43503cc12dafdcdbc9ab1e17d.0;rport=5060.
Via: SIP/2.0/UDP 172.31.13.202:5060;rport=5060;received=13.232.78.75;branch=z9hG4bK-20254-2186327-0.
From: <sip:919980950111@21979254854757081.zt.plivo.com>;tag=2186327.
To: <sip:919980950111@21979254854757081.zt.plivo.com>.
Call-ID: 2186327-20254@172.31.13.202.
CSeq: 1 INVITE.
Server: kamailio (5.1.3 (x86_64/linux)).
Content-Length: 0.
.

#
U 172.31.4.160:5060 -> 54.183.198.87:5060
SIP/2.0 408 Request Timeout.
Via: SIP/2.0/UDP 54.183.198.87:5060;branch=z9hG4bK223b.cd9c3cb1d2dc6adc346e6fb7acdee708.0;rport=5060.
Via: SIP/2.0/UDP 172.31.13.202:5060;rport=5060;received=13.232.78.75;branch=z9hG4bK-20254-2185727-0.
From: <sip:919980950111@21979254854757081.zt.plivo.com>;tag=2185727.
To: <sip:919980950111@21979254854757081.zt.plivo.com>;tag=c99e9820d9036d36e5541ff825b95248-8c22.
Call-ID: 2185727-20254@172.31.13.202.
CSeq: 1 INVITE.
Server: kamailio (5.1.3 (x86_64/linux)).
Content-Length: 0.
.

</code></pre>
<h4>Log Messages</h4>

<pre><code>Jun 29 19:18:14 ip-172-31-4-160 kamailio[8119]: ERROR: <core> [core/mem/q_malloc.c:287]: qm_find_free(): qm_find_free(0x7fe974b24000, 35992); Free fragment not found!
Jun 29 19:18:14 ip-172-31-4-160 kamailio[8119]: ERROR: <core> [core/mem/q_malloc.c:421]: qm_malloc(): qm_malloc(0x7fe974b24000, 35992) called from http_async_client: http_multi.c: curl_shm_calloc(346), module: http_async_client; Free fragment not found!
Jun 29 19:18:14 ip-172-31-4-160 kamailio[8119]: ERROR: http_async_client [http_multi.c:437]: new_request(): curl_easy_init() failed!
</code></pre>
<h4>SIP Traffic</h4>

<pre><code>(paste your sip traffic here)
</code></pre>
<h3>Possible Solutions</h3>

<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>(paste your output here)
</code></pre>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>

<pre><code>root@ip-172-31-4-160:/etc/kamailio# uname -a
Linux ip-172-31-4-160 3.13.0-143-generic #192-Ubuntu SMP Tue Feb 27 10:45:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/1577">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZQJdc0p7QianpqrkHlxcf9fXFAcHks5uBn4RgaJpZM4U9gZo">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZRy2vl0dWjHS4aoh4uUEzl3BjNn7ks5uBn4RgaJpZM4U9gZo.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"MemoryUtilization getting increase with lua routing (#1577)"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1577"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/1577",
"url": "https://github.com/kamailio/kamailio/issues/1577",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "MemoryUtilization getting increase with lua routing (#1577)",
"sections": [
{
"text": "",
"activityTitle": "**Surendra Tiwari**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@SurendraPlivo",
"facts": [
{
"name": "Repository: ",
"value": "kamailio/kamailio"
},
{
"name": "Issue #: ",
"value": 1577
}
]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1577,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close issue",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1577\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/kamailio/kamailio/issues/1577"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 351667816\n}"
}
],
"themeColor": "26292E"
}
]</script>