最近在學(xué)習(xí)使用mongodb,發(fā)現(xiàn)它內(nèi)存占用厲害,網(wǎng)上搜索了一下發(fā)現(xiàn)很多都利用use admin;db.runCommand({closeAllDatabases:1})來清除內(nèi)存,我在3.0中發(fā)現(xiàn)沒有該命令,
是3.0中取消了該命令還是我的打開的方法不對,查看了一下手冊也沒有發(fā)現(xiàn)類似的替代命令,請問最新版本中還有該命令么?如果有的話,應(yīng)該怎么使用呢?
I am also learning mongodb recently. I recommend you mongodb learning materials http://www.hubwiz.com/course/54bdfcb188dba012b4b95c9c/
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?