--max-old-space-size
A V8 option, passed to node, that sets the maximum size in megabytes of old space, the largest part of the JavaScript heap.
In more detail
When old space reaches the limit and garbage collection cannot free enough, the process crashes with a "JavaScript heap out of memory" error. In a container, set it somewhat below the container memory limit so V8 collects garbage harder before the kernel's OOM killer steps in.
Related terms
- heap space — One of the separate regions V8 divides its heap into, such as new space for young objects and old space for long-lived ones.
- memory limit — The most memory a container may use before the kernel kills a process inside it.
- OOM killer — The part of the Linux kernel that kills a process when memory runs out.
- NODE_OPTIONS — An environment variable holding command-line options that every node process started in that environment applies, including child processes.
Taught in
- Runtime Configuration: CLI Flags & Native --env-file — Node.js Internals & Backend Services
- Production Hardening: Graceful Shutdown & Docker — Node.js Internals & Backend Services