A Node.js process crashes with `FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory`.
IntermediateTroubleshootingProcesses, memory and OOM
Answer
Likely causes → V8's heap limit was reached (default depends on version and available memory), not the OS limit; or a leak.
Diagnose →
node -e 'console.log(v8.getHeapStatistics().heap_size_limit/1024/1024)'
ps -o rss,cmd -p <PID>
Fix → Raise the heap if usage is legitimate: NODE_OPTIONS=--max-old-space-size=3072, keeping it below the container/cgroup limit. Take heap snapshots (--heapsnapshot-near-heap-limit=2) to find leaks.
Prevent → Align runtime heap limits with cgroup limits; monitor heap usage.
More on Processes, memory and OOM
A Java service disappears without an error in its own log. `dmesg` shows `Out of memory: Killed process 4121 (java) total-vm:... anon-rss:...`.BeginnerA service gets killed with `Memory cgroup out of memory: Killed process ...` but the host has 20 GB free.Intermediate`ps` shows dozens of processes in state `Z` with `<defunct>`.BeginnerZombie count keeps climbing into the thousands and new processes fail with `fork: Resource temporarily unavailable`.AdvancedAn app crashes under load with `java.io.IOException: Too many open files` (or `EMFILE`).BeginnerYou raised `nofile` in `/etc/security/limits.conf` to 65536, but the service still shows `Max open files 1024`.Intermediate