Out of memory on rebuild with 4GB swap?

This looks less like a pnpm or Ember issue, and more like the host simply running out of memory.

The key detail is the SIGKILL. That usually means the OS stepped in and killed the process (often via the OOM killer), not that ember build -prod failed on its own.

On small hosts, Ember production builds can easily spike to a couple of GB of RAM. Even with swap enabled, once swap is mostly used, the kernel can still decide to kill a memory-hungry node process.

A few things that point in this direction:

  • Swap is already heavily used when the failure happens.
  • The failure is much more likely when another container is running at the same time.
  • If I stop the other container before running the bootstrap, the exact same build succeeds.

So swap helps a bit, but it mostly just delays the problem. Stopping other containers lowers memory pressure enough for the build to finish.

What helped / might help:

  • Avoid running multiple bootstraps or asset builds in parallel.
  • Stop other containers during ember build -prod.
  • Cap Node’s memory usage (e.g. NODE_OPTIONS=--max_old_space_size=1024) to reduce peak usage.
  • If possible, bumping the host RAM (4GB+) makes this a lot more reliable.

Hopefully this helps explain why it feels a bit random and why stopping another container makes it work.

2 Likes