Node stops a process that tries to grow the V8 heap past its limit and prints a fatal error ending in JavaScript heap out of memory. The limit exists so one process cannot consume the machine. Two very different problems produce this message: the process legitimately needs more memory than the default cap allows (large builds, big in-memory data), or it leaks, holding references so memory climbs until any cap would eventually fail. The fix depends entirely on which one it is.
process.memoryUsage().heapUsed periodically). A leak climbs steadily during steady work and never settles; a limit problem jumps when a big job arrives and is stable otherwise.NODE_OPTIONS=--max-old-space-size=4096 (megabytes) in the service or build configuration, sized to what the machine or container actually has, and record why, an unexplained large cap hides the next leak.--inspect with Chrome DevTools, or v8.writeHeapSnapshot()) and compare, the growing constructor or collection names the culprit.--max-old-space-size on a leaking process only buys time, it converts a daily crash into a weekly one. If memory climbs monotonically during steady work, treat it as a leak until a snapshot comparison proves otherwise.
What is the default heap limit in Node? It varies by Node version and platform; recent 64-bit builds scale it with total system memory, up to roughly 4 GB, while constrained environments get far less. Print it with node --v8-options or observe where the process dies.
Does this error occur in browsers too? Browsers manage per-tab memory differently and usually kill or reload the tab instead of printing this message. The wording is characteristic of Node and other V8 server runtimes.
Can garbage collection settings prevent it? Flags can tune collection timing, but they cannot create memory. If live data exceeds the cap, only a higher cap, less retained data, or streaming changes the outcome.