How do I determine the correct “max-old-space-size” for node.js?

后端 未结 4 1592
别跟我提以往
别跟我提以往 2020-12-07 11:52

I\'m having some trouble to understand how Node.js acts based on the parameter max-old-space-size.

In my case, for example, I\'m running two t2.sma

4条回答
  •  生来不讨喜
    2020-12-07 12:07

    This error occurs when the memory allocated for the executing application is less than the required memory. By default, the memory limit in Node.js is 512 MB. To increase this amount, you need to set the memory limit argument —-max-old-space-size. It will help avoid a memory limit issue.

    node --max-old-space-size=1024 index.js #increase to 1gb
    node --max-old-space-size=2048 index.js #increase to 2gb
    node --max-old-space-size=3072 index.js #increase to 3gb
    node --max-old-space-size=4096 index.js #increase to 4gb
    node --max-old-space-size=5120 index.js #increase to 5gb
    node --max-old-space-size=6144 index.js #increase to 6gb
    node --max-old-space-size=7168 index.js #increase to 7gb
    node --max-old-space-size=8192 index.js #increase to 8gb
    

    https://medium.com/@vuongtran/how-to-solve-process-out-of-memory-in-node-js-5f0de8f8464c

提交回复
热议问题