每天五分钟轻松学运维2019-05-17: Linux清空缓存–技术流ken



free -m 命令可以查看内存使用情况

[root@ken ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 777M 755M 1.9M 306M 879M
Swap: 4.0G 261M 3.7G






[root@ken ~]# sync
[root@ken ~]# sync





[root@ken ~]# echo “3” > /proc/sys/vm/drop_caches


上面的echo 3 是清理所有缓存

echo 0 是不释放缓存

echo 1 是释放页缓存

ehco 2 是释放dentries和inodes缓存

echo 3 是释放 1 和 2 中说道的的所有缓存


1>. /proc是一个虚拟文件系统,我们可以通过对它的读写操作作为与kernel实体间进行通信的一种手段。也就是说可以通过修改/proc中的文件,来对当前kernel的行为做出调整。也就是说我们可以通过调整/proc/sys/vm/drop_caches来释放内存。
0 – 不释放
1 – 释放页缓存
2 – 释放dentries和inodes
3 – 释放所有缓存
2>. 关于drop_caches的官方说明如下:
Writing to this file causes the kernel to drop clean caches,dentries and inodes from memory, causing that memory to becomefree.
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches;
to free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >/proc/sys/vm/drop_caches.
Because this is a non-destructive operation and dirty objects are not freeable, the user should run sync first.
3>. Linux内核会将它最近访问过的文件页面缓存在内存中一段时间,这个文件缓存被称为pagecache。


total = used + free

[oracle@cddserver1 ~]$ free -m
             total       used       free     shared    buffers     cached
Mem:         32096      10379      21717          0         38       7942
-/+ buffers/cache:       2398      29698
Swap:        34287          0      34287
2. Linux的内存分配方式

echo 1 > /proc/sys/vm/drop_caches 可以暂时清空cache和buffer

10 thoughts on “每天五分钟轻松学运维2019-05-17: Linux清空缓存–技术流ken

  1. Aw, this was a really nice post. In thought I want to put in writing like this additionally ?taking time and precise effort to make a very good article?however what can I say?I procrastinate alot and by no means seem to get something done.

  2. My husband and i ended up being really glad when Ervin could carry out his homework using the precious recommendations he got through the weblog. It’s not at all simplistic to simply choose to be giving freely secrets and techniques that many a number of people could have been selling. So we recognize we now have the writer to give thanks to for this. All of the illustrations you’ve made, the simple site navigation, the friendships you can make it easier to instill – it’s most awesome, and it is letting our son and us believe that that content is satisfying, and that is rather essential. Thank you for the whole lot!

  3. I in addition to my friends ended up taking note of the best advice found on your web page and immediately developed an awful feeling I never thanked the web blog owner for those strategies. My guys came thrilled to study all of them and now have in actuality been taking advantage of these things. Appreciation for indeed being considerably considerate as well as for selecting this kind of impressive guides millions of individuals are really eager to be informed on. My very own sincere apologies for not expressing appreciation to you earlier.

  4. My spouse and i felt quite lucky John managed to finish off his investigations through the entire precious recommendations he made using your web page. It is now and again perplexing to simply continually be making a gift of guidelines the rest could have been making money from. And we do know we need the blog owner to give thanks to for that. The specific explanations you made, the easy website menu, the friendships you can make it easier to instill – it’s mostly powerful, and it is aiding our son in addition to us believe that this concept is thrilling, which is certainly truly vital. Many thanks for the whole thing!

  5. I together with my pals happened to be following the nice helpful hints on the blog while the sudden I got a horrible feeling I never thanked the blog owner for them. My boys came as a consequence excited to read through all of them and now have undoubtedly been loving those things. Appreciation for really being considerably considerate and then for using this kind of impressive information millions of individuals are really desperate to be aware of. My very own honest regret for not expressing gratitude to you earlier.

  6. I wanted to type a simple remark to be able to express gratitude to you for all of the great ways you are showing at this website. My incredibly long internet search has at the end of the day been recognized with awesome strategies to write about with my neighbours. I would assert that we readers actually are unquestionably blessed to be in a notable website with very many special individuals with helpful hints. I feel very much blessed to have encountered your site and look forward to really more brilliant minutes reading here. Thanks a lot once more for a lot of things.

  7. I want to convey my gratitude for your generosity giving support to those people that require help on this particular niche. Your special dedication to getting the solution throughout had been unbelievably beneficial and have consistently allowed those like me to get to their goals. Your own helpful information indicates a lot a person like me and a whole lot more to my office workers. Thanks a ton; from all of us.

  8. I would like to voice my respect for your kind-heartedness for individuals that should have help on this one topic. Your very own commitment to getting the solution across has been especially helpful and has in most cases made men and women much like me to get to their endeavors. Your entire invaluable instruction can mean a lot a person like me and additionally to my colleagues. Warm regards; from everyone of us.

  9. I intended to send you that very small word so as to thank you very much over again on the striking solutions you’ve provided on this page. It has been quite tremendously generous of people like you to provide extensively precisely what most of us would have advertised for an e-book to get some money for their own end, and in particular now that you could possibly have tried it in case you considered necessary. These good ideas as well acted to be a fantastic way to be sure that some people have the identical interest similar to my very own to know a whole lot more around this issue. I believe there are thousands of more enjoyable sessions up front for individuals who looked over your site.

  10. Thanks so much for giving everyone such a splendid chance to check tips from here. It really is very ideal and as well , jam-packed with amusement for me and my office mates to visit your website the equivalent of thrice a week to find out the newest secrets you have. Not to mention, I am just actually satisfied concerning the spectacular opinions served by you. Certain 4 tips on this page are without a doubt the most suitable we have all had.

supreme clothing进行回复 取消回复