How to solve process out of memory in Node.js

I will showing how to solve process out of memory in Node.js.

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed — process out of memory
Same issue output with Node.js v6.7

This error occurs when the memory allocated for the execution application is less than the required memory when run application.

By default the memory limit in Node.js is 512 mb, to solve this issue you need to increasing the memory limit use command —- max-old-space-size .It can be avoid the memory limit issue.


node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb

That’s it.
Happy coding!