how to release the caching which is used by Mongodb?

MongoDB will (at least seem) to use up a lot of available memory, but it actually leaves it up to the OS’s VMM to tell it to release the memory (see Caching in the MongoDB docs.)

You should be able to release any and all memory by restarting MongoDB.

However, to some extent MongoDB isn’t really “using” the memory.

For example from the MongoDB docs Checking Server Memory Usage

Depending on the platform you may see
the mapped files as memory in the
process, but this is not strictly
correct. Unix top may show way more
memory for mongod than is really
appropriate. The Operating System (the
virtual memory manager specifically,
depending on OS) manages the memory
where the “Memory Mapped Files”
reside. This number is usually shown
in a program like “free -lmt”.

It is called “cached” memory.

MongoDB uses the LRU (Least Recently Used) cache algorithm to determine which “pages” to release, you will find some more information in these two questions …

Leave a Comment