NodeJS – Heap out of memory

Spread the love

Sometimes, when you work with a lot of data you can get the error:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed – JavaScript heap out of memory . It happening because of default limit for heap in NodeJS (~ 1.5 GB).

For fix it just use parameter:

--max-old-space-size

with size (in megabytes) that which you need.

Sample:

node --max-old-space-size=4096 test.js

Leave a Reply