簡體   English   中英

使用foreverjs並在Heroku上運行的nodejs應用避免垃圾

[英]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_sizegc_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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM