node - invalid array length

匿名 (未验证) 提交于 2019-12-03 02:15:02

问题:

I'm using node v0.12.4. When I run the following code with node --max-old-space-size=8192 test.js it gives me the error FATAL ERROR: invalid array length Allocation failed - process out of memory

var a = new Array(200000000); console.log(a.length); 

However if I change the size to 300000000 I don't get any error. What's going on here? Is there some command line argument aside from --max-old-space-size I need to change?

回答1:

V8's heap size is limited to 1 GB for 64 bit and 512 for 32-bit machine, but Buffer objects exist largely outside the heap. you can expand the memory use up to 1.7 GB in 64-bit and ~1 GB in 32-bit machine. You can try this.

--max-old-space-size=3000  --trace-gc-verbose 

you can print the trace to know about the memory use.



回答2:

There is a limit of memory.64bit Machines can use about 1.6gb.This is the limit of V8 compiler. this links maybe can help you

Configuring v8's memory management to be smart for a node.js process

https://groups.google.com/forum/#!topic/nodejs/BQ5dSm8lITQ



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!