Skip to content

Instantly share code, notes, and snippets.

@motss
Last active April 9, 2024 06:24
Show Gist options
  • Save motss/f55b92ccab0d434fa6e6cfd07423014b to your computer and use it in GitHub Desktop.
Save motss/f55b92ccab0d434fa6e6cfd07423014b to your computer and use it in GitHub Desktop.
[TIPS] Increase memory limit in Node.js

By default the memory limit in Node.js is 512MB.

This will cause FATAL ERROR- JS Allocation failed – process out of memory when processing large data files.

It can be avoided by increasing the memory limit.

See Command-line options for more details.

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

How to increase memory usage for certain CLI tools, e.g. rollup:

node --max-old-space-size=8192 node_modules/rollup/bin/rollup -c rollup-config.js
@motss
Copy link
Author

motss commented Feb 8, 2021

not working

@Tomato6966 It's fixed now. Thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment