简体   繁体   English

使用foreverjs并在Heroku上运行的nodejs应用避免垃圾

[英]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: 根据Heroku的文档,为避免产生垃圾 ,您可以在Procfile中为V8提供标志:

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: 但是,我的应用程序使用foreverjs ,并且在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 ? 有没有办法提供--max_old_space_sizegc_interval=100类的标志,并且仍然使用foreverjs

I'm using pm2 not forever but as it seems that forever as this syntax : 我不是永远使用pm2,但似乎永远都使用这种语法:

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

I would try to put those in the script-options part : 我会尝试将它们放在script-options部分中:

./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. 无论哪种方式,我都不会强制使用gc的时序。max_old_space_size应该与您的节点进程可用的RAM相符,并且在您的情况下,如果您的节点进程占用的RAM大于约500M,应该自己触发一次gc调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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