[SERVER-4354] Waiting mongo process leaks memory. Created: 22/Nov/11  Updated: 11/Jul/16  Resolved: 12/Dec/11

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 2.0.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mark G B Assignee: Brandon Diamond
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS X 10.7.2. 8GB RAM, 2.3 GHz Intel Core i5 Macbook Pro


Operating System: ALL
Participants:

 Description   

Very long running query from the shell (mongo) (doing nothing), kills memory/swap on the client machine. mongod is not running on same machine.

e.g. run this and wait 5 hours and look at swap.

var conn = new Mongo('mongo_machine_ip');
var some_db = conn.getDB('some_db');

var mysleep = function(){

var conn = new Mongo();
var some_db = conn.getDB('some_db');
sleep(1000*60*60*5);
return [1,2];
};

var a = forces.eval(mysleep);
print(a);



 Comments   
Comment by Brandon Diamond [ 12/Dec/11 ]

Ah – fantastic. Thanks so much for the extra details; we'll keep that info in mind if we encounter any similar reports in the future. Glad that things are working as expected.

Comment by Mark G B [ 12/Dec/11 ]

Apologies. Here is a better explanation:

I was running Mongo on a virtualized Linux in VMWare which was running on OS/X.
OS/X apparently has issues with memory mapped files and creating empty swap. See the discussion here http://stackoverflow.com/questions/2017283/c-program-stuck-on-uninterruptible-wait-while-performing-disk-i-o-on-mac-os-x-sn

I guess VMWare is optimized in such a way that the problem creates excess swap in OS/X even when it's running in the virtualized Linux. Linux swap remains unused, therefore I assumed the problem was in OS/X, where the only thing running (other than VMWare) was mongo. Hence, I thought it was the mongo client.

I was creating a new mongo because it seemed mysleep was not properly capturing it's scope when sent to the server using eval. So I had to reconstruct a new Mongo in the function.

Comment by Brandon Diamond [ 12/Dec/11 ]

I've been unable to reproduce this issue. Memory usage has increased at a fairly normal rate on my machine; most of it due to Firefox which was running at the same time.

Out of curiosity, is there a reason you're constructing a new Mongo() in the mysleep function? I wonder if this might have something to do with what you're seeing.

Comment by Mark G B [ 22/Nov/11 ]

2nd last line should have been

var a = some_db.eval(mysleep);

Generated at Thu Feb 08 03:05:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.