mongodb memory usage is going high even if only insertions are made mongodb memory usage is going high even if only insertions are made mongodb mongodb

mongodb memory usage is going high even if only insertions are made


There is an excellent discussion of how MongoDB uses storage and memory here:

http://docs.mongodb.org/manual/faq/storage/

Specifically to your case, Mongo memory maps the files that data and indexes live in (the ones inside of /data/db directory by default) which means that the files are mapped to OS's virtual address space and then whenever MongoDB accesses a page (any part of the file) that page will get pulled into RAM and it will stay there until all of RAM that's made available to mongod process by the OS is used (at that point least-recently-used pages will be swapped out of RAM).

You are inserting data and therefore you are writing to data files - those pages you are writing to need to be in RAM (mongo writes to files but since they are memory mapped it gets to interact with memory as if it's disk storage). If mongod is using 20GB+ of RAM that means your data plus your indexes (plus some overhead for other things) are 20GB or more.