[Asterisk-code-review] pbx.c: Include filesystem cache in free memory calculation (asterisk[13])

Sean Bright asteriskteam at digium.com
Thu Jan 16 07:37:05 CST 2020


Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13597 )


Change subject: pbx.c: Include filesystem cache in free memory calculation
......................................................................

pbx.c: Include filesystem cache in free memory calculation

ASTERISK-28695 #close
Reported by: Kevin Flyn

Change-Id: Ief098bb6eb77378daeace8f97ba30701c8de55b8
---
A doc/CHANGES-staging/minmemfree.txt
M main/pbx.c
2 files changed, 8 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/97/13597/1

diff --git a/doc/CHANGES-staging/minmemfree.txt b/doc/CHANGES-staging/minmemfree.txt
new file mode 100644
index 0000000..5762c15
--- /dev/null
+++ b/doc/CHANGES-staging/minmemfree.txt
@@ -0,0 +1,5 @@
+Subject: minmemfree
+
+The 'minmemfree' configuration option now counts memory allocated to
+the filesystem cache as "free" because it is memory that is available
+to the process.
diff --git a/main/pbx.c b/main/pbx.c
index 6584735..3d73a7b 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -4571,7 +4571,7 @@
 	int failed = 0;
 	double curloadavg;
 #if defined(HAVE_SYSINFO)
-	long curfreemem;
+	unsigned long curfreemem;
 	struct sysinfo sys_info;
 #endif
 
@@ -4593,8 +4593,8 @@
 	if (option_minmemfree) {
 		if (!sysinfo(&sys_info)) {
 			/* make sure that the free system memory is above the configured low watermark
-			 * convert the amount of freeram from mem_units to MB */
-			curfreemem = sys_info.freeram * sys_info.mem_unit;
+			 * convert the amount of available RAM from mem_units to MB */
+			curfreemem = (sys_info.freeram + sys_info.bufferram) * sys_info.mem_unit;
 			curfreemem /= 1024 * 1024;
 			if (curfreemem < option_minmemfree) {
 				ast_log(LOG_WARNING, "Available system memory (~%ldMB) is below the configured low watermark (%ldMB)\n", curfreemem, option_minmemfree);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13597
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: Ief098bb6eb77378daeace8f97ba30701c8de55b8
Gerrit-Change-Number: 13597
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200116/fd945dfd/attachment.html>


More information about the asterisk-code-review mailing list