Crate kumo_server_memory

source ·
Expand description

This module contains logic to reason about memory usage, implement memory limits, and some helpers to attempt to release cached memory back to the system when memory is low.

Structs§

Functions§

  • Returns the amount of headroom; the number of bytes that can be allocated before we hit the soft limit
  • 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.
  • Returns true when we are within 10% if the soft limit
  • To be called when a thread goes idle; it will flush cached memory out of the thread local cache to be returned/reused elsewhere in the system
  • Initialize the memory thread to monitor memory usage/limits
  • Returns a receiver that will notify when memory status changes from OK -> !OK or vice versa.