数据库 - mongodb如何 清除占用的内存
世界只因有你
世界只因有你 2017-04-26 09:01:54
0
2
996

最近在学习使用mongodb,发现它内存占用厉害,网上搜索了一下发现很多都利用use admin;db.runCommand({closeAllDatabases:1})来清除内存,我在3.0中发现没有该命令,

是3.0中取消了该命令还是我的打开的方法不对,查看了一下手册也没有发现类似的替代命令,请问最新版本中还有该命令么?如果有的话,应该怎么使用呢?

世界只因有你
世界只因有你

reply all(2)
洪涛

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.

  1. If you are in a production environment, there is no need to reclaim memory at all, because it will only make the instant efficiency very poor. And it doesn't work, because the database will reload the data from the disk later, causing high disk IO and affecting the write speed. So in the end, you only get temporary free memory, and query speed and write speed will be greatly affected. You can figure it out for yourself whether it’s a good deal or not.
  2. If this is a development environment and you don’t need to worry about these problems, restarting mongod can easily solve the problem. In addition, because you may want to further clear the data in the cache, you can use the Linux command: echo 3 > /proc/sys/vm/drop_caches

Reference:
Does MongoDB require a lot of RAM?
How do you empty the buffers and cache on a Linux system?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template