Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Quick Start

Use an admission gate around the work that creates memory pressure.

#![allow(unused)]
fn main() {
use memory_admission::sync::AdmissionGate;

let gate = AdmissionGate::new_default();

let permit = gate.acquire();
// Run memory-sensitive work while the permit is held.
drop(permit);
}

For async workloads, use the Tokio-friendly gate:

#![allow(unused)]
fn main() {
use memory_admission::r#async::AdmissionGate;

let gate = AdmissionGate::new_default();

let permit = gate.acquire().await;
// Run memory-sensitive async work while the permit is held.
drop(permit);
}