Rust Compile OOM / SIGKILL (Exit 137) in CI
The kernel OOM-killer terminated rustc (or the linker) mid-compile because the build exhausted the runner’s memory. The process is SIGKILLed, surfacing as exit code 137 or signal: 9 (SIGKILL).
What this error means
The build dies abruptly with process didn't exit successfully ... signal: 9 (SIGKILL) or the job ends with exit 137, often during a large crate or the final link. There is no compiler diagnostic - the process was killed from outside.
error: could not compile `heavy-crate` (lib)
Caused by:
process didn't exit successfully: `rustc ...` (signal: 9, SIGKILL: kill)
# job exit code: 137Common causes
Build memory exceeded the runner
Optimized builds, heavy generics/macros, LTO, and high parallelism all raise peak memory. On a small runner the total exceeds available RAM and the OOM-killer steps in.
Too many parallel codegen jobs
Cargo compiles many crates and codegen units in parallel by default. Each rustc process holds memory, and the concurrent peak can blow the limit.
How to fix it
Reduce parallelism and codegen units
Fewer concurrent jobs and codegen units lower peak memory at some cost to wall time.
# fewer parallel rustc processes
cargo build -j 2
# and in profile:
[profile.release]
codegen-units = 1Trim memory-heavy settings or grow the runner
- Disable LTO (
lto = false) or use thin LTO if a release build OOMs. - Lower the debug-info level (
debug = 1) to shrink object sizes. - Move the job to a larger-memory runner when the build genuinely needs it.
How to prevent it
- Cap
-jandcodegen-unitson memory-constrained runners. - Avoid full LTO in CI unless a release artifact requires it.
- Size the runner to the build’s real peak memory.