Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
611 views
in Technique[技术] by (71.8m points)

javascript - node - invalid array length

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...