Expand description
Memory-pressure helpers for chaos testing.
These helpers allocate (and hold) bytes to simulate a system under memory pressure. They DO NOT trigger OOM; the OS or Rust allocator will respond to allocation failure normally. They DO reliably consume the requested amount of process memory while the returned guard is live.
§Use cases
- Verify that retry loops handle
Errfrom allocation-prone paths. - Exercise code that consults available memory before issuing large operations (e.g. buffered I/O, image decoding).
- Pair with
crate::FailureScheduleto simulate “memory pressure → operation fails” scenarios deterministically.
§Limits
- This is user-space pressure. It cannot simulate kernel-level
exhaustion (NUMA, cgroups, swap thrashing) — for that you need
OS-level fault injection, which is out of scope for
dev-chaos. - The allocation is held in
Vec<u8>form; the OS may compress, page out, or otherwise account for it differently than “wasted” memory in real workloads. - Released on drop, like every other RAII guard in the suite.
Structs§
- Memory
Pressure - A memory-pressure guard that holds
size_bytesof allocated memory for its entire lifetime.