I am using Node.js. I have the following javascript code.
var length=9980;
this.distance= [];//hold distance
this.cost= []; //hold time cost
console.log("before create distance and cost arrays");
console.log("length" + length);
for(var i=0; i < length;i++)
{
console.log("creating cost : " + i );
this.distance[i] = new Array(length);
this.cost[i] = new Array(length);
};
By this, I want to create 2 dimension array of
distance, cost
as shown above.
The problem there is error reported.
Array should be able to hold millions of elements, but there is such error.
What is the problem? How can I make it work?
I think you are running into node's default memory limits.
Try adding running your node app with the --max_old_space_size= flag.
node --max_old_space_size=4096 app.js
According to http://prestonparry.com/articles/IncreaseNodeJSMemorySize/ the number is in megabytes so this should give you a memory cap of 4GB.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.