In mongodb i work with this collection:

Size     55.93g 
Data Size    39.82g
Storage Size 41.08g 
Extents  53 
Indexes  4 
Index Size   9.64g

It takes few seconds of mongdb being up with this single collection and all 48GB RAM on the dedicated server are gone.

That's worse because there is also a mysqld+nginx/fcgi on this machine which should be allowed to use at least 24GB together. I.e. remaining 24GB, enough for the mongod!

However, it does not share in a fair way. Everybody says that the memory for mongod is managed by OS and releases unneccessary space for other processes if they demand RAM. On my machine it is not releasing RAM. What's wrong?


             total       used       free     shared    buffers     cached`
Mem:      49559136   49403908     155228          0      57284   47247564
-/+ buffers/cache:    2099060   47460076
Swap:      8008392        164    8008228
  • Could you append the output of the "free" command? Jun 22, 2012 at 13:36
  • done in the top posting
    – ledy
    Jun 22, 2012 at 13:45
  • 1
    's/linux/mongodb' -- linuxatemyram.com Jun 22, 2012 at 14:16
  • Sounds like normal MongoDB performance to me. Jun 22, 2012 at 14:55

1 Answer 1


As you see in your output of free, 47460076 byte are cached. They are freed if needed. Don't worry you have plenty of memory and mongoDB won't eat it. It just takes a bit of ram that is immediately freed when other applications really need it.

  • how to define the number of MB to be reserved as "backup" ram? mongod seems to take care of at least 100-300M (or doesn't want them...) In case of emergency it takes some time to release the ram and i had the oom-killer doing the job which is not the proper way!
    – ledy
    Jun 26, 2012 at 6:22
  • What would be an emergency? You might read through this page posted above: linuxatemyram.com Jun 26, 2012 at 20:32
  • Mongo should be on a dedicated box/VM. I tried running it with apache/mysql with horrible results whenever I had a spike on apache, because mongod had claimed too much RAM and apache was tuned to use more than was available (which was almost nothing) without a lot of page faults. My advice: keep mongodb away from other programs, you'll thank me later. Jun 28, 2012 at 19:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .