<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Monospace;
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">We are looking into the memory leaks. We are heavily using BGAPI with lua interface.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">We are currently closely looking into switch_event_queue_dispatch_event method. We don’t get why are we setting the values as NULL and not destroying the event.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none"><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">static</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><span style="font-size:10.0pt;font-family:Monospace;color:#005032">switch_status_t</span><span style="font-size:10.0pt;font-family:Monospace;color:black">
<b>switch_event_queue_dispatch_event</b>(</span><span style="font-size:10.0pt;font-family:Monospace;color:#005032">switch_event_t</span><span style="font-size:10.0pt;font-family:Monospace;color:black"> **eventp)</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">{</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><span style="font-size:10.0pt;font-family:Monospace;color:#005032">switch_event_t</span><span style="font-size:10.0pt;font-family:Monospace;color:black"> *event = *eventp;</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">if</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black"> (!SYSTEM_RUNNING) {</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">return</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><i><span style="font-size:10.0pt;font-family:Monospace;color:#0000C0">SWITCH_STATUS_FALSE</span></i><span style="font-size:10.0pt;font-family:Monospace;color:black">;</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> }</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">while</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black"> (event) {</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">int</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black"> launch = 0;</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> switch_mutex_lock(EVENT_QUEUE_MUTEX);</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">if</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black"> (!PENDING && switch_queue_size(EVENT_DISPATCH_QUEUE) > (</span><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">unsigned</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">int</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black">)(DISPATCH_QUEUE_LEN * DISPATCH_THREAD_COUNT)) {</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">if</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black"> (SOFT_MAX_DISPATCH + 1 < MAX_DISPATCH) {</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> launch++;</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> PENDING++;</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> }</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> }</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> switch_mutex_unlock(EVENT_QUEUE_MUTEX);</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">if</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black"> (launch) {</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">if</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black"> (SOFT_MAX_DISPATCH + 1 < MAX_DISPATCH) {</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">
<span style="background:silver;mso-highlight:silver">switch_event_launch_dispatch_threads</span>(SOFT_MAX_DISPATCH + 1);</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> }</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> switch_mutex_lock(EVENT_QUEUE_MUTEX);</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> PENDING--;</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> switch_mutex_unlock(EVENT_QUEUE_MUTEX);</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> }</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black">
<span style="background:yellow;mso-highlight:yellow">*eventp = NULL; </span></span><span style="font-size:10.0pt;font-family:Monospace;background:yellow;mso-highlight:yellow"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black;background:yellow;mso-highlight:yellow"> switch_queue_push(EVENT_DISPATCH_QUEUE, event);
</span><span style="font-size:10.0pt;font-family:Wingdings;color:black;background:yellow;mso-highlight:yellow">ß</span><span style="font-size:10.0pt;font-family:Monospace;color:black;background:yellow;mso-highlight:yellow"> We are pushing the event in the
queue</span><span style="font-size:10.0pt;font-family:Monospace;background:yellow;mso-highlight:yellow"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black;background:yellow;mso-highlight:yellow"> event = NULL;</span><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><span style="font-size:10.0pt;font-family:Wingdings;color:black">ß</span><span style="font-size:10.0pt;font-family:Monospace;color:black"> we are just setting this value as NULL. Shouldn’t we destroy the event using switch_event_destroy method?</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace;color:black"> }</span><span style="font-size:10.0pt;font-family:Monospace"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:Monospace"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><b><span style="font-size:10.0pt;font-family:Monospace;color:#7F0055">return</span></b><span style="font-size:10.0pt;font-family:Monospace;color:black">
</span><i><span style="font-size:10.0pt;font-family:Monospace;color:#0000C0">SWITCH_STATUS_SUCCESS</span></i><span style="font-size:10.0pt;font-family:Monospace;color:black">;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:Monospace;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal">Help in this regard is highly appreciated.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks<o:p></o:p></p>
<p class="MsoNormal">Darshan<o:p></o:p></p>
</div>
</body>
</html>