We recently started seeing a spate of node processes dying with the unhelpful error:
FATAL ERROR: JS Allocation failed - process out of memory
Unfortunately, there’s no callstack provided. A StackOverflow answer suggested installing the OFE package, which got us a “heapdump” but it still wasn’t obvious what the problem was.
Eventually we spotted a pattern in the logs, and adding more logging led to a reproducible test case. It turned out that the bug was caused by using an array instead of an object (“hashmap”):
var foo = []; foo[1000000001] = {}; console.log('got here'); console.log(foo); console.log('boom!');
Accessing the array with a high id caused a huge array to be created, and trying to print that array caused the process to consume all the available memory.
UPDATE: we’re not the only ones to run into this issue.