Mongodb memory usage too high


Official documentation on memory usage…

Starting from mongodb 3.4, the maximum memory occupied is: (computer memory – 1 / 2)

Starting in MongoDB 3.4, the default WiredTiger internal cache size is the larger of either:

50% of (RAM – 1 GB), or
256 MB.

For example, my computer has 16g memory. Mongodb will occupy 7.5GB at most. It’s disgusting

The key is that using mongodump and mongorestore will also consume a lot of memory and will not release

Modify configuration

We can limit the memory size used by mongodb by modifying the configuration…

Note that the level of the configuration item is: storage.wiredtiger.engineconfig.cachesizegb

  ... other configurations
      cacheSizeGB: 3

Before the modification, I used mongorestore, and the memory occupied about 6G. After the modification, the memory occupied only 3G, which is effective in the personal test

Recommended Today

Swift advanced (XV) extension

The extension in swift is somewhat similar to the category in OC Extension can beenumeration、structural morphology、class、agreementAdd new features□ you can add methods, calculation attributes, subscripts, (convenient) initializers, nested types, protocols, etc What extensions can’t do:□ original functions cannot be overwritten□ you cannot add storage attributes or add attribute observers to existing attributes□ cannot add parent […]