rust.unbounded_memory
Stability
High
Detects data structures that can grow without bounds, leading to OOM.
Why It Matters
Section titled “Why It Matters”Unbounded memory:
- Causes OOM — Process killed by OS
- Cascading failures — Other services impacted
- Hard to diagnose — Gradual memory growth
Example
Section titled “Example”// ❌ Before (unbounded Vec)fn collect_items(stream: impl Stream<Item = Item>) -> Vec<Item> { let mut items = Vec::new(); while let Some(item) = stream.next().await { items.push(item); // Grows forever! } items}// ✅ After (with capacity limit)fn collect_items(stream: impl Stream<Item = Item>, max: usize) -> Vec<Item> { let mut items = Vec::with_capacity(max.min(1000)); while let Some(item) = stream.next().await { if items.len() >= max { break; // Stop at limit } items.push(item); } items}What Unfault Detects
Section titled “What Unfault Detects”- Vecs without capacity hints growing in loops
- HashMaps accepting unbounded input
- Channels without buffer limits
Auto-Fix
Section titled “Auto-Fix”Unfault adds capacity limits and bounds checks.