Procedural 2d-array mongoDB insert on node.js runs out of memory

I am trying to insert a 2000 x 2000 2d array into my mongoDB instance via my node.js server.

Right now the way i'm doing it is:

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);
        }

Now, the problem I am facing is that at around line 576 my node.js instance slows down dramatically (one line processed per 40 seconds or so) and then runs out of memory. I don't understand how/why this is happening.

Am I approaching this problem correctly? Any ideas on how I can get this 2d array into my database without floundering?

Thanks for your help all.

Answers


It looks like the problem is with the provider of my mongoDB instance. I just found out that when spooling a mongo instance on jitsu there is a ~64MB limit on the size of the memory usage. Thus, at exactly that point, I got the "out of memory" error.

Wish they would somehow make the error message a bit more descriptive including what device was running out of memory... rolls eyes.

Case closed.


Need Your Help

Debugging asserts in Qt Creator

c++ qt qt-creator

When I hit a normal assert statement while debugging with Visual Studio I get the option to break into the debugger so I can see the entire stack trace and the local variables, not just the assert

How to block window.showModalDialog popups from a BHO?

javascript internet-explorer popup bho showmodaldialog

I am working on a BHO popups / ads blocker, and I can't find how to block this js triggered popup:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.