From eaede003824690dd72ebc0daf9e6f063a0993e8d Mon Sep 17 00:00:00 2001 From: William Brown Date: Oct 05 2017 21:58:08 +0000 Subject: Ticket 49392 - memavailable not available Bug Description: On certain linux platforms memAvailable is not actually available! This means that the value was 0, so cgroup max was read instead, setting the system ram to: 9223372036854771712 That's a bit excessive, and can cause memory allocations to fail. Fix Description: If memavail can't be found, fall back to memtotal instead. https://pagure.io/389-ds-base/issue/49392 Author: wibrown Review by: mreynolds (Thanks!) --- diff --git a/ldap/servers/slapd/slapi_pal.c b/ldap/servers/slapd/slapi_pal.c index 52e914f..e41a0c4 100644 --- a/ldap/servers/slapd/slapi_pal.c +++ b/ldap/servers/slapd/slapi_pal.c @@ -153,7 +153,16 @@ spal_meminfo_get() { /* Both memtotal and memavail are in kb */ memtotal = memtotal * 1024; - memavail = memavail * 1024; + + /* + * Oracle Enterprise Linux doesn't provide a valid memavail value, so fall + * back to 80% of memtotal. + */ + if (memavail == 0) { + memavail = memtotal * 0.8; + } else { + memavail = memavail * 1024; + } /* If it's possible, get our cgroup info */ uint64_t cg_mem_soft = 0;