1

My mongod command

mongod --wiredTigerCacheSizeGB 5

In practice, I'm getting mongo instance to use even up to 8.6 GB (on a VM with 50 GB RAM)

Indexes are using about 100 MB (checked with db.stats())

tcmalloc information:

MALLOC:     3776745552 ( 3601.8 MiB) Bytes in use by application
MALLOC: +   4744544256 ( 4524.8 MiB) Bytes in page heap freelist
MALLOC: +     20067616 (   19.1 MiB) Bytes in central cache freelist
MALLOC: +      3584128 (    3.4 MiB) Bytes in transfer cache freelist
MALLOC: +     12470800 (   11.9 MiB) Bytes in thread cache freelists
MALLOC: +     22544384 (   21.5 MiB) Bytes in malloc metadata
MALLOC:   ------------
MALLOC: =   8579956736 ( 8182.5 MiB) Actual memory used (physical + swap)
MALLOC: +     29933568 (   28.5 MiB) Bytes released to OS (aka unmapped)
MALLOC:   ------------
MALLOC: =   8609890304 ( 8211.0 MiB) Virtual address space used
MALLOC:
MALLOC:          21650              Spans in use
MALLOC:             59              Thread heaps in use
MALLOC:           4096              Tcmalloc page size

The server had been running for 3 days.

How can I tell why mongo is consuming more memory than the allowed cache size? Is there any way to manually free up the "page heap freelist"?

The command output is recommending Call ReleaseFreeMemory() to release freelist memory to the OS, but I don't think I can actually do that out of the process.

MongoDB version is 4.4.1, I'm using mongo:4.4.1-bionic docker image.

1

The maximum cache size is just that - a limit on the size of the cache used by the underlying storage engine.

If you run queries, sort things, make connections, etc, those all require memory outside of the cache.

MongoDB uses tcmalloc for memory management, which doesn't immediately release memory back to the OS when the program calls free.

You can adjust how tcmalloc releases memory with the tcmallocAggressiveMemoryDecommit server parameter added here: https://jira.mongodb.org/browse/SERVER-16829

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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