-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Bug Description
When running Tiny Shell under moderate load (spawning/exiting many child processes), memory usage grows over time and is not reclaimed. After ~1000 short-lived commands, the process RSS steadily increases until OOM occurs on constrained containers.
To Reproduce
Steps to reproduce the behavior:
- Build and run Tiny Shell:
git checkout <commit-hash>
cargo build --release
- Run a loop to spawn multiple short-lived processes:
for i in $(seq 1 2000); do ./target/release/tinysh -c "true"; done
- Monitor memory usage:
# In a separate terminal
watch -n 1 'ps aux | grep tinysh | head -n 1'
Expected Behavior
Memory footprint should remain stable with resources being properly freed after each child process exits.
Actual Behavior
- Resident memory (RSS) steadily increases and is not freed
- Observed ~10–20MB leak per 100–200 commands (platform dependent)
- Eventually leads to OOM in memory-constrained containers
Environment
- OS: Ubuntu 22.04 / macOS 12
- Rust Version: stable (1.70.0 – please specify exact version)
- Build Command: cargo build --release
- Commit:
- Module: tiny-shell
Additional Context / Investigation Clues
- No panic or crash observed during execution
- valgrind / jemalloc profiling suggests missing cleanup in process table or wait handling
- Suspected issue in child reaping path (wait() / waitpid() calls)
- Memory appears to accumulate with each process spawn/exit cycle