How to solve process out of memory in Node.js

Vuong Tran
Oct 27, 2016 · 1 min read

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!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store