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

后端 未结 4 1575
别跟我提以往
别跟我提以往 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:04

    2020 Update

    These options are now documented officially by node. For a 2GB machine, you should probably use:

    NODE_OPTIONS=--max-old-space-size=1536
    

    To determine the amount to use: You can see available memory on a Linux machine using free -m. Note that you can use the free and the buffers/cache memory combined, as buffers/cache can be thrown away (these buffers and cache are a nice way to use otherwise unused memory).

    Note the official documentation formax-old-space-size also mentions:

    On a machine with 2GB of memory, consider setting this to 1536 (1.5GB)

    Hence the value above. Consider that the amount of memory needed for the base OS doesn't change much, so you could happily do 3.5 on a 4GB machine etc.

提交回复
热议问题