mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 04:30:28 +00:00
pbx.c: Include filesystem cache in free memory calculation
ASTERISK-28695 #close Reported by: Kevin Flyn Change-Id: Ief098bb6eb77378daeace8f97ba30701c8de55b8
This commit is contained in:
5
doc/CHANGES-staging/minmemfree.txt
Normal file
5
doc/CHANGES-staging/minmemfree.txt
Normal file
@@ -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.
|
12
main/pbx.c
12
main/pbx.c
@@ -4614,7 +4614,6 @@ static int increase_call_count(const struct ast_channel *c)
|
|||||||
int failed = 0;
|
int failed = 0;
|
||||||
double curloadavg;
|
double curloadavg;
|
||||||
#if defined(HAVE_SYSINFO)
|
#if defined(HAVE_SYSINFO)
|
||||||
long curfreemem;
|
|
||||||
struct sysinfo sys_info;
|
struct sysinfo sys_info;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -4634,13 +4633,16 @@ static int increase_call_count(const struct ast_channel *c)
|
|||||||
}
|
}
|
||||||
#if defined(HAVE_SYSINFO)
|
#if defined(HAVE_SYSINFO)
|
||||||
if (option_minmemfree) {
|
if (option_minmemfree) {
|
||||||
|
/* Make sure that the free system memory is above the configured low watermark */
|
||||||
if (!sysinfo(&sys_info)) {
|
if (!sysinfo(&sys_info)) {
|
||||||
/* make sure that the free system memory is above the configured low watermark
|
/* Convert the amount of available RAM from mem_units to MB. The calculation
|
||||||
* convert the amount of freeram from mem_units to MB */
|
* was done this way to avoid overflow problems */
|
||||||
curfreemem = sys_info.freeram * sys_info.mem_unit;
|
uint64_t curfreemem = sys_info.freeram + sys_info.bufferram;
|
||||||
|
curfreemem *= sys_info.mem_unit;
|
||||||
curfreemem /= 1024 * 1024;
|
curfreemem /= 1024 * 1024;
|
||||||
if (curfreemem < option_minmemfree) {
|
if (curfreemem < option_minmemfree) {
|
||||||
ast_log(LOG_WARNING, "Available system memory (~%ldMB) is below the configured low watermark (%ldMB)\n", curfreemem, option_minmemfree);
|
ast_log(LOG_WARNING, "Available system memory (~%" PRIu64 "MB) is below the configured low watermark (%ldMB)\n",
|
||||||
|
curfreemem, option_minmemfree);
|
||||||
failed = -1;
|
failed = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user