码迷,mamicode.com
首页 > 系统相关 > 详细

(转)Linux下清理Cache方法

时间:2016-02-14 12:54:47      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:

频繁的文件访问会导致系统的Cache使用量大增, 系统运行缓慢。

1 首先用free 命令查看内存的使用:
$ free -m
             total       used       free     shared    buffers     cached
Mem:   3955       3926         28          0         55            3459

2 运行sync将dirty的内容写回硬盘
$sync
3 通过修改proc系统的drop_caches清理free的cache
$echo 3 > /proc/sys/vm/drop_caches


关于drop_caches的详细文档如下:
Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.
To free pagecache:
    * echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
    * echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
    * echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed.

 

参考文献:

[1] 转载地址:http://m.blog.csdn.net/article/details?id=4336075.

(转)Linux下清理Cache方法

标签:

原文地址:http://www.cnblogs.com/dpc525/p/5188854.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!