I have deployed a Mongo Community server docker in WSL Ubuntu and currently running MongoDB aggregate Query and downloading some data from Mongo. I set up the Mongo memory limit to 32 GB. However, after my query ran Mongo occupied around 22.4 GB. enter image description here

To fix this I added Mongo tcmallocReleaseRate as 9.0 in /etc/mongod.conf file.

  tcmallocReleaseRate: 9.0

However, still, my memory usage is very high enter image description here

This is adding a heavy load on our servers despite my mongo operation being finished. I am wondering how can I tell Mongo to free up this memory to system.

  • 1
    Did you configure the cache size in mongod.conf?
    – Joe
    Dec 12, 2023 at 19:13
  • @joe no do I need to? I was wondering it would use the memory when it needs to but free up later shouldn't this be the case? Dec 12, 2023 at 20:04
  • The mongod will hold on to 80% of the cache persistently, if left to its own defaults, it will set it cache size to about 50% of the amount of memory that the OS reports is there.
    – Joe
    Dec 12, 2023 at 20:28
  • 2
    Fred differently: what's the underlying problem that you're trying to solve here? Dec 12, 2023 at 20:55
  • @user20042973 basically when we do DB-intensive operations it crashes our whole DB, due to memory usage. Trying to resolve it Dec 13, 2023 at 6:02


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.