Function kumo_server_memory::get_usage_and_limit
source · pub fn get_usage_and_limit() -> Result<(MemoryUsage, MemoryLimits)>
Expand description
Retrieves the current usage and limits. This is a bit of a murky area as, on Linux, the cgroup reported usage appears to be nonsensical when no limits are configured. So we first obtain the limits from cgroups, and if they are set, we return the usage from cgroups along with it, otherwise we get the ulimit limits and look at the more general usage numbers to go with it.
If no limits are explicitly configured, we’ll assume a hard limit equal to the physical ram on the system, and a soft limit of 75% of whatever we’ve determined the hard limit to be.