2

我正在尝试通过我的 node.js 服务器将 2000 x 2000 2d 数组插入到我的 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 秒左右处理一行),然后内存不足。我不明白这是如何/为什么会发生的。

我是否正确地解决了这个问题?关于如何在不费力的情况下将这个二维数组放入我的数据库的任何想法?

谢谢大家的帮助。

4

1 回答 1

1

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

希望他们能以某种方式使错误消息更具描述性,包括什么设备内存不足......翻白眼

结案。

于 2012-08-24T00:08:32.580 回答