node.js上的程序2d数组mongoDB插入内存不足

我想通过我的node.js服务器插入一个2000 x 2000二维数组到我的mongoDB实例。

现在我这样做的方式是:

for (i=0; i<2000; i++){ //i = height of the tile map for(x=0; x<2000; x++){ //x is the width of the tile map driver.mongo.insert('worldTiles', {loc: [x,i], elevation: obj.server.theArray[i][x]}, function (err,results){ if(!err){ }else{ console.log('Ran into an error inserting into worldTiles on Mongo'); } }) } console.log(i); } 

现在,我面临的问题是,在576行左右,我的node.js实例显着减速(每40秒处理一行),然后内存不足。 我不明白这是怎么发生的。

我正确地处理这个问题吗? 任何想法,我怎么可以得到这个二维数组到我的数据库没有挣扎?

感谢您的帮助。

看起来问题是我的mongoDB实例的提供者。 我刚刚发现,在jitsu上假脱机mongo实例时,内存使用的大小有一个〜64MB的限制。 因此,正是在这一点上,我得到了“内存不足”的错误。

希望他们能以某种方式使错误信息更具描述性,包括哪些设备耗尽内存…… 卷眼睛

案件结案。