<h3>Description</h3>

<p>We are buidling some kind of our own rtpengine dispatcher based on our own algorithm using kemi Lua.</p>
<p>In one of the functions we are calling:</p>
<p>`local reqBody = function(command, params)</p>
<pre><code>return json.encode({
    jsonrpc = "2.0",
    method = "rtpengine." .. command,
    params = params
})
</code></pre>
<p>end</p>
<p>KSR.jsonrpcs.exec(reqBody("show", { "all" }))<br>
local data = json.decode(KSR.pv.get("$jsonrpl(body)"))<br>
`<br>
And watching <strong>free_mem</strong> decrasing in case of  every call of this function</p>
<p>If we are commenting this - nothing happens</p>
<p>P.S. We are doing the same for the dispatcher module but did not find memory leak for it:</p>
<p>`local reqBody = function (command,params)</p>
<pre><code>return  json.encode( { 
    jsonrpc = "2.0", 
    method  = "dispatcher." ..command, 
    params  = params 
} )
</code></pre>
<p>end</p>
<p>KSR.jsonrpcs.exec(reqBody( "list" ) )<br>
local data = json.decode( KSR.pv.get("$jsonrpl(body)") )<br>
`</p>
<h3>Troubleshooting</h3>
<h4>Reproduction</h4>
<p>To reproduce this issue suppose will be enough to call code above</p>
<h4>Debugging Data</h4>
<p>test results for 10000 calls total/300 per second (sipp based)</p>
<p>memory stats on the start</p>
<p>shmem:fragments = 2 |  <br>
shmem:free_size = 63131408<br>
shmem:max_used_size = 3994704<br>
shmem:real_used_size = 3977456<br>
shmem:total_size = 67108864<br>
shmem:used_size = 3205144</p>
<p>memory stats on the end</p>
<p>shmem:fragments = 5 |  <br>
shmem:free_size = 60106232<br>
shmem:max_used_size = 7019952<br>
shmem:real_used_size = 7002632<br>
shmem:total_size = 67108864<br>
shmem:used_size = 4150008</p>
<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>version: kamailio 5.1.6 (x86_64/linux) 7d1964
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 7d1964
compiled on 03:23:23 Oct  5 2018 with gcc 6.3.0
</code></pre>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>

<pre><code>1 machine: SMP Debian 4.9.110-3+deb9u6 (2018-10-08) x86_64 GNU/Linux
2 machine: SMP Debian 4.9.110-3+deb9u2 (2018-08-13) x86_64 GNU/Linux
</code></pre>
<p>If will need any additional info just let me know<br>
P.S. We also tried to find what can give this behavior on the rtpengine.c but didn't figured out yet</p>

<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/1778">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZSTxS8SVzUlW4PS9EoXesPbd7ev9ks5u8NOsgaJpZM4ZgcND">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZVTw5BpZoIG53C1m_ZbcDeBCrcZtks5u8NOsgaJpZM4ZgcND.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://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"jsonrpcs_exec for the rtpengine cache gives memory leak (#1778)"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1778"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/1778",
"url": "https://github.com/kamailio/kamailio/issues/1778",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>