#limit #resources #effective #mem #allocation

bin+lib effective-limits

Estimate effective resource limits for a process e.g. how much RAM is available for use.

10 releases

0.5.5 Nov 20, 2022
0.5.4 Mar 10, 2022
0.5.3 Jul 3, 2021
0.5.2 Oct 10, 2020
0.3.0 Feb 24, 2020

#244 in Memory management

Download history 538/week @ 2024-07-23 785/week @ 2024-07-30 364/week @ 2024-08-06 342/week @ 2024-08-13 514/week @ 2024-08-20 343/week @ 2024-08-27 371/week @ 2024-09-03 439/week @ 2024-09-10 467/week @ 2024-09-17 506/week @ 2024-09-24 352/week @ 2024-10-01 409/week @ 2024-10-08 297/week @ 2024-10-15 267/week @ 2024-10-22 130/week @ 2024-10-29 122/week @ 2024-11-05

955 downloads per month

Apache-2.0

26KB
525 lines

Estimate effective resource limits for a process

effective-limits is a mid-level API for determining the effective limits upon a process. It combines e.g. mem_info and getrlimit.

The goal is to have a good chance of avoiding failed allocations without requiring either developer or user a-priori selection of memory limits. That is, how much memory is effectively available for this process to use, considering the physical machine and ulimits, but not the impact of noisy neighbours, swappiness and so on. This limit can then be used to inform the size of in memory caches, put a threshold on in or output file buffers and so on.

#![warn(clippy::all)]

extern crate effective_limits;

fn main() -> effective_limits::Result<()> {
    println!("Effective mem limit: {}", effective_limits::memory_limit()?);
    Ok(())
}

Dependencies

~0.3–1MB
~19K SLoC