[英]Avoid garbage with nodejs app using foreverjs and running on Heroku
根据Heroku的文档,为避免产生垃圾 ,您可以在Procfile中为V8提供标志:
web: node --optimize_for_size --max_old_space_size=460 --gc_interval=100 server.js
但是,我的应用程序使用foreverjs ,并且在Procfile中使用以下指令:
web: ./node_modules/.bin/forever -m 5 server.js
有没有办法提供--max_old_space_size
或gc_interval=100
类的标志,并且仍然使用foreverjs ?
我不是永远使用pm2,但似乎永远都使用这种语法:
usage: forever [action] [options] SCRIPT [script-options]
我会尝试将它们放在script-options部分中:
./node_modules/.bin/forever -m 5 server.js --max_old_space_size=460 --gc_interval=100
无论哪种方式,我都不会强制使用gc的时序。max_old_space_size应该与您的节点进程可用的RAM相符,并且在您的情况下,如果您的节点进程占用的RAM大于约500M,应该自己触发一次gc调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.