<p>Joshua Colp <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13637">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
George Joseph: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pbx.c: Include filesystem cache in free memory calculation<br><br>ASTERISK-28695 #close<br>Reported by: Kevin Flyn<br><br>Change-Id: Ief098bb6eb77378daeace8f97ba30701c8de55b8<br>---<br>A doc/CHANGES-staging/minmemfree.txt<br>M main/pbx.c<br>2 files changed, 12 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/minmemfree.txt b/doc/CHANGES-staging/minmemfree.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..5762c15</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/minmemfree.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: minmemfree</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The 'minmemfree' configuration option now counts memory allocated to</span><br><span style="color: hsl(120, 100%, 40%);">+the filesystem cache as "free" because it is memory that is available</span><br><span style="color: hsl(120, 100%, 40%);">+to the process.</span><br><span>diff --git a/main/pbx.c b/main/pbx.c</span><br><span>index 872d674..f7b813b 100644</span><br><span>--- a/main/pbx.c</span><br><span>+++ b/main/pbx.c</span><br><span>@@ -4614,7 +4614,6 @@</span><br><span> int failed = 0;</span><br><span> double curloadavg;</span><br><span> #if defined(HAVE_SYSINFO)</span><br><span style="color: hsl(0, 100%, 40%);">- long curfreemem;</span><br><span> struct sysinfo sys_info;</span><br><span> #endif</span><br><span> </span><br><span>@@ -4634,13 +4633,16 @@</span><br><span> }</span><br><span> #if defined(HAVE_SYSINFO)</span><br><span> if (option_minmemfree) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Make sure that the free system memory is above the configured low watermark */</span><br><span> if (!sysinfo(&sys_info)) {</span><br><span style="color: hsl(0, 100%, 40%);">- /* make sure that the free system memory is above the configured low watermark</span><br><span style="color: hsl(0, 100%, 40%);">- * convert the amount of freeram from mem_units to MB */</span><br><span style="color: hsl(0, 100%, 40%);">- curfreemem = sys_info.freeram * sys_info.mem_unit;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Convert the amount of available RAM from mem_units to MB. The calculation</span><br><span style="color: hsl(120, 100%, 40%);">+ * was done this way to avoid overflow problems */</span><br><span style="color: hsl(120, 100%, 40%);">+ uint64_t curfreemem = sys_info.freeram + sys_info.bufferram;</span><br><span style="color: hsl(120, 100%, 40%);">+ curfreemem *= sys_info.mem_unit;</span><br><span> curfreemem /= 1024 * 1024;</span><br><span> if (curfreemem < option_minmemfree) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Available system memory (~%ldMB) is below the configured low watermark (%ldMB)\n", curfreemem, option_minmemfree);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "Available system memory (~%" PRIu64 "MB) is below the configured low watermark (%ldMB)\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ curfreemem, option_minmemfree);</span><br><span> failed = -1;</span><br><span> }</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13637">change 13637</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13637"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ief098bb6eb77378daeace8f97ba30701c8de55b8 </div>
<div style="display:none"> Gerrit-Change-Number: 13637 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>