最近在学习使用mongodb,发现它内存占用厉害,网上搜索了一下发现很多都利用use admin;db.runCommand({closeAllDatabases:1})来清除内存,我在3.0中发现没有该命令,
是3.0中取消了该命令还是我的打开的方法不对,查看了一下手册也没有发现类似的替代命令,请问最新版本中还有该命令么?如果有的话,应该怎么使用呢?
PHP中文网2017-04-26 09:03:54
I am also learning mongodb recently. I recommend you mongodb learning materials http://www.hubwiz.com/course/54bdfcb188dba012b4b95c9c/
怪我咯2017-04-26 09:03:54
Many people think that there is a problem with the database taking up too much memory. In fact, this is not a problem at all and does not need to be solved.
First of all, the primary task of a database is to manage data. How to provide data queries faster is a problem that all databases need to solve. The solutions of each company are almost the same. Whether it is SQLServer, MySQL, or MongoDB, they all trade space for efficiency. In layman's terms, it is to use as much memory as possible and load all useful things (indexes, data, etc.) into memory as much as possible to improve running speed. So, this is definitely not a bug, but expected behavior. Thinking about it conversely, if a database runs slowly in order to save memory, this violates the basic purpose of a database.
Once you understand this, let’s look at your question.
Reference:
Does MongoDB require a lot of RAM?
How do you empty the buffers and cache on a Linux system?