A fork() failed with ENOMEM: the kernel could not reserve memory for a new process. On a memory-tight runner this hits when overall usage (or a process/thread cap) is already near the limit.
What this error means
A command fails with fork: Cannot allocate memory or Resource temporarily unavailable, often while a build spawns many subprocesses. Freeing memory or using a larger runner clears it.
With little free RAM (and no swap headroom), the kernel cannot satisfy the fork allocation.
Too many concurrent processes
High build parallelism spawns more processes than the runner can back with memory.
How to fix it
Lower concurrency and free memory
Reduce parallel processes and reclaim RAM before the heavy step.
shell
free -h
make -j2 # instead of -j$(nproc)
# drop caches is host-only; prefer fewer workers in CI
Add memory headroom
Run on a runner with more RAM.
Raise a tight container --memory limit.
Cap parallel jobs/tests to the runner size.
How to prevent it
Match build parallelism to runner cores and RAM.
Right-size memory for fork-heavy build systems.
Watch free -h in CI before heavy steps.
Frequently asked questions
What causes "fork: cannot allocate memory"?
With little free RAM (and no swap headroom), the kernel cannot satisfy the fork allocation.
How do I fix fork: cannot allocate memory?
Reduce parallel processes and reclaim RAM before the heavy step.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.