nodejs out of memory

后端 未结 3 1070
时光取名叫无心
时光取名叫无心 2020-12-23 12:09

I came across a curious issue today. This may be an easy answer for others, but it has me stumped. Why does the code below cause a memory error?

var cur =          


        
3条回答
  •  抹茶落季
    2020-12-23 12:31

    I don't get a memory allocation error when I run your script. How much RAM is on your system?

    Edit Ok with the author's updated notes, I can replicate it.

    Node is trying to convert your entire array to a string. The array is 16777216 elements long. Each element contains a number at least 9 digits long. Converting that to a string 150,994,994 characters long. Its just a huge operation that is exceeding the memory capabilities of node.

提交回复
热议问题