Skip to content

Instantly share code, notes, and snippets.

  • Save neto-developer/249041599d8f13b751833351292ba687 to your computer and use it in GitHub Desktop.
Save neto-developer/249041599d8f13b751833351292ba687 to your computer and use it in GitHub Desktop.
Disable PM2 Vizion feature to save IO and Memory Usage and avoid "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory"

Disable PM2 Vizion feature to save IO and Memory Usage and avoid "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory"

A feature do pm2 chamada "vizion" tenta indexar o repositório do projeto de cada comando rodando. Em grandes repositórios e principalmente com um grande numero de processos rodando isso pode causar um grande consumo de memória e IO, o que impacta drasticamente a performance da maquina e dependendo da maquin, pode causar: "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory"

A seguir salvamos o estado do pm2 no arquivo ~/.pm2/dump.pm2, matamos o PM2 God Daemon e todos os processos que ele gerencia, alteramos o dumo.pm2 desativando a flag do "vizion" e ressucitamos o pm2 ao estado original.

pm2 save
pm2 kill 
cd ~/.pm2/
sed -i 's/"vizion": true/"vizion": false/g' dump.pm2
pm2 resurrect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment