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 that it 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
Note: If you have specified export NODE_OPTIONS=<value>
in your package.json
, it'll override what you set in the NODE_OPTIONS
environment variable in the config.yml
(either at the container, job, or step respective level)
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
Comments
Article is closed for comments.