Crates.io | cgroup-memory |
lib.rs | cgroup-memory |
version | 0.1.0 |
source | src |
created_at | 2024-09-18 20:06:47.314045 |
updated_at | 2024-09-18 20:06:47.314045 |
description | A library for reading and interpreting `/sys/fs/cgroup` memory statistics. |
homepage | |
repository | https://github.com/sdtnjung/cgroup-memory.git |
max_upload_size | |
id | 1379579 |
size | 21,745 |
A Rust crate for reading and interpreting /sys/fs/cgroup
memory statistics.
/sys/fs/cgroup/memory.stat
/sys/fs/cgroup/memory.max
match memory_max() {
Ok(Some(v)) => println!("Max memory: {v}"),
Ok(None) => println!("No max memory constraint"),
Err(e) => println!("Failed to read and parse memory files: {e}"),
}
match memory_available() {
Ok(Some(v)) => println!("Available memory: {v} bytes"),
Ok(None) => println!("No memory limit set"),
Err(e) => println!("Failed to read memory information: {}", e),
}
These tests require environments with specific memory attributes. We utilize Docker to create such virtual Linux environments.
Note that memory.max
only contains a valid value if the --memory
option was specified.
docker build -t cgroup-memory
# Run tests that expect 100mb of total memory
docker run --rm --memory=100m cgroup-memory /usr/local/bin/cargo-nextest ntr --archive-file test_memory_max_100m.tar.zst --workspace-remap . --no-capture