简体   繁体   中英

Avoid garbage with nodejs app using foreverjs and running on Heroku

According to Heroku doc, to avoid garbage , you can provide flags to V8 in your Procfile:

web: node --optimize_for_size --max_old_space_size=460 --gc_interval=100 server.js

However, my app uses foreverjs , and I use the following instruction in the Procfile:

web: ./node_modules/.bin/forever -m 5 server.js

Is there a way to provide flags like --max_old_space_size or gc_interval=100 and still use foreverjs ?

I'm using pm2 not forever but as it seems that forever as this syntax :

usage: forever [action] [options] SCRIPT [script-options]

I would try to put those in the script-options part :

./node_modules/.bin/forever -m 5 server.js --max_old_space_size=460 --gc_interval=100

Either way, I wouldn't force the timing of the gc... The max_old_space_size should be in acordance to the RAM you have available for your node process, and in your case, if your node process take more than ~500M of RAM it should trigger a gc call by himself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM