Search code examples
node.jsforever

How to set memory limit to NodeJS running with forever


I'm running my Node JS process through forever as below:

sudo forever start -o out.log -e error.log myServer.js

I want to change the memory limit of my NodeJs server as I do like below when I'm running it purely with node.

node --max-old-space-size=512 myServer.js

How I can do the same when I'm running it with forever? Is there some way like 'forever start --max-old-space-size=512'


Solution

  • You can pass node options by changing the command (which defaults to "node").

    So for example:

    sudo forever start -c "node --max_old_space_size=512" -o out.log -e error.log myServer.js