Node.js catch ENOMEM error thrown after spawn

前端 未结 6 1593
孤独总比滥情好
孤独总比滥情好 2020-12-02 06:33

My Node.js script crashes because of a thrown ENOMEM (Out of memory) errnoException when using spawn.

The error:

child_process.js:935
  throw errnoEx         


        
6条回答
  •  有刺的猬
    2020-12-02 07:31

    You can try changing the amount of memory node uses with this command: node ----max-old-space-size=1024 yourscript.js

    --max-old-space-size=1024 will allocate 1 gig of memory.

    By default node will use 512 mb of ram but depending on your platform you may need to allocate more or less so the garbage collection kicks in when you need it.

    If your platform has less than 500 mb of ram available then try setting the memory usage lower to --max-old-space-size=256.

提交回复
热议问题