How can I increase the max memory for Node?

Node has a default max memory usage of less than 2GB on some 64bit systems. This can cause unexpected memory issues when running on CircleCI. It's possible to adjust the max memory ceiling using a command line flag passed into node:

--max-old-space-size=<memory in MB>

 

The flag can be difficult to ensure is being used. Especially when node processes are forked. The best way to ensure this setting will be picked up by all node processes within the environment is to apply this setting directly to an environment variable, which can be done using Node. 8 or higher

NODE_OPTIONS=--max_old_space_size=4096

 

Further Reading:

https://futurestud.io/tutorials/node-js-increase-the-memory-limit-for-your-process

https://stackoverflow.com/questions/48387040/nodejs-recommended-max-old-space-size/48392705

Was this article helpful?
18 out of 50 found this helpful

Comments

0 comments

Please sign in to leave a comment.