Error AtlasError Documentation and Resolution

Node.js exhausted its JavaScript heap

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

V8 could not allocate more JavaScript heap space within its limit. A large legitimate workload and a memory leak can produce the same failure, so raising the limit should follow measurement rather than replace diagnosis.

JavaScript heap out of memorymemory
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
  • A build or application holds a large dataset or too many simultaneous tasks in memory.
  • A cache, listener, or retained object graph grows without a bound.
  • The heap limit is too small for the workload or the container has insufficient overall memory.
  1. Identify which Node process failed and observe memory across repeated runs or requests. Consistent growth suggests retained data; a stable peak may indicate workload sizing.
  2. Reduce peak memory with streaming, batching, bounded caches, and controlled concurrency before increasing limits.
  3. If the workload legitimately needs more heap, set --max-old-space-size to a measured MiB value within the deployment memory budget. Leave room for native allocations, buffers, other processes, and the operating system.
  4. Capture heap diagnostics in a controlled environment if needed. Heap snapshots can pause execution, consume substantial memory, and contain sensitive data; do not collect or publish them casually on production systems.
  5. Distinguish a V8 fatal heap message from a container OOM kill: increasing the heap limit can worsen a container-level memory shortage.
Node.js Docs: --max-old-space-size