I'm testing MongoDB for archives data. We have a collection with 160M rows. MongoDB instance takes 76.2 Gb virtual memory on a 12 Gb physical memory box ;-) The swap in null.

I read that virtual memory = physical + swap.

What's wrong in my case ? It this a problem for mongoDB itself ?



MongoDB uses memory mapped files - which can be much larger then the actual physical (or swap) available on your machine. The total virtual memory used will usually be the size of all the data on disk at the time as a result.

The resident memory will be the stat that represents the actual working set used, though depending on your resources on the box and the usage pattern this will tend to grow over time and approach the total physical RAM on the host. Basically, unless the OS sees a need to page out old data (memory pressure) it will stay in RAM.

When you restart MongoDB this basically starts again from scratch. So if you have a known time frame for your actual working data set (say you only ever use the last 7 days), then the set size after that time period (assuming regular, predictable use) will represent your approximate working set size in terms of RAM.

More info to be found in the Docs here:



Finally, MMS (which is free) does a good job of mapping this out for you over time - Mapped, Virtual, Resident and non-Mapped as well as plenty of other stats (look for "i" over each graph for an explanation).


  • Can you please define "disk" in your statement "The total virtual memory used will usually be the size of all the data on disk at the time as a result". Is disk the entire mount / volume on a Linux where mongo is installed, or is just the physical data directory where mongo would store the datafiles? Simply putting "disk" doesnt make much sense. – user2654744 Oct 16 '13 at 22:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.