Mongod resident memory usage low Mongod resident memory usage low mongodb mongodb

Mongod resident memory usage low


It appears this was being caused by a large amount of inactive memory on the server that wasn't be cleared for Mongo's use.

By looking at the result from:

cat /proc/meminfo

I could see a large amount of Inactive memory. Using this command as a sudo user:

free && sync && echo 3 > /proc/sys/vm/drop_caches && echo "" && free

Freed up the inactive memory, and over the next 24 hours I was able to see the resident memory of my Mongo instance increasing to consume the rest of the memory available on the server.

Credit to the following blog post for it's instructions:

http://tinylan.com/index.php/article/how-to-clear-inactive-memory-in-linux


MongoDB only uses as much memory as it needs, so if all of the data and indexes that are in MongoDB can fit inside what it's currently using you won't be able to push that anymore.

If the data set is larger than memory, there are a couple of considerations:

  • Check MongoDB itself to see how much data it thinks its using by running mongostat and looking at resident-memory
  • Was MongoDB re/started recently? If it's cold then the data won't be in memory until it gets paged in (leading to more page faults initially that gradually settle). Check out the touch command for more information on "warming MongoDB up"
  • Check your read ahead settings. If your system read ahead is too high then MongoDB can't efficiently use the memory on the system. For MongoDB a good number to start with is a setting of 32 (that's 16 KB of read ahead assuming you have 512 byte blocks)


I had the same issue: Windows Server 2008 R2, 16 Gb RAM, Mongo 2.4.3. Mongo uses only 2 Gb of RAM and generates a lot of page faults. Queries are very slow. Disk is idle, memory is free. Found no other solution than upgrade to 2.6.5. It helped.