Linux下清理内存和Cache方法 /proc/sys/vm/drop_caches

时间:2021-10-26 18:42:37

Linux下清理内存和Cache方法 /proc/sys/vm/drop_caches

频繁的文件访问会导致系统的Cache使用量大增

$ free -m
total used free shared buffers cached
Mem:
-/+ buffers/cache:
Swap:

free内存减少到几十兆,系统运行缓慢

运行sync将dirty的内容写回硬盘
$sync

通过修改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 > /proc/sys/vm/drop_caches
To free dentries and inodes:
* echo > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
* echo > /proc/sys/vm/drop_caches
As this is a non-destructive operation, and dirty objects are notfreeable, the user should run "sync" first in order to make sure allcached objects are freed.
This tunable was added in 2.6..

修改/etc/sysctl.conf 添加如下选项后就不会内存持续增加

vm.dirty_ratio =
vm.dirty_background_ratio=
vm.dirty_writeback_centisecs=
vm.dirty_expire_centisecs=
vm.drop_caches=
vm.swappiness =
vm.vfs_cache_pressure=
vm.overcommit_memory=
vm.lowmem_reserve_ratio=
kern.maxvnodes=

上面的设置比较粗暴,使cache的作用基本无法发挥。需要根据机器的状况进行适当的调节寻找最佳的折衷。

Linux下清理内存和Cache方法 /proc/sys/vm/drop_caches的更多相关文章

  1. Linux下清理内存和Cache方法

    暂时目前的环境处理方法比较简单: 在root用户下添加计划任务: */10 * * * * sync;echo 3 > /proc/sys/vm/drop_caches; 每十分钟执行一次,先将 ...

  2. Linux下清理内存和Cache方法见下文:

    暂时目前的环境处理方法比较简单: 在root用户下添加计划任务: */10 * * * * sync;echo 3 > /proc/sys/vm/drop_caches; 每十分钟执行一次,先将 ...

  3. Linux/Centos下清理内存和Cache方法

    Linux/Centos下释放内存和缓存方法 $ free -m 运行sync将dirty的内容写回硬盘$ sync 通过修改proc系统的drop_caches清理free的cache$ echo ...

  4. /proc/sys/vm/drop_caches 清理缓存

    1. 使用方法 /proc/sys/vm/drop_caches默认是0 # echo 1 > /proc/sys/vm/drop_caches; free pagecache, use# ec ...

  5. Linux中的Buffer Cache和Page Cache echo 3 > /proc/sys/vm/drop_caches Slab内存管理机制 SLUB内存管理机制

    Linux中的Buffer Cache和Page Cache echo 3 > /proc/sys/vm/drop_caches   Slab内存管理机制 SLUB内存管理机制 http://w ...

  6. linux内存——/proc/sys/vm/drop_caches

      原贴:http://www.linuxfly.org/post/320/ http://blog.csdn.net/chinalinuxzend/article/category/265273/2 ...

  7. 手工释放linux内存——/proc/sys/vm/drop_caches

    --手工释放linux内存——/proc/sys/vm/drop_caches 总有很多朋友对于Linux的内存管理有疑问,之前一篇日志似乎也没能清除大家的疑虑.而在新版核心中,似乎对这个问题提供了新 ...

  8. [转]手工释放linux内存——/proc/sys/vm/drop_caches

    另一篇:http://www.linuxfly.org/post/320/   1.清理前内存使用情况 free -m 2.开始清理  echo 1 > /proc/sys/vm/drop_ca ...

  9. Linux下查看内存使用情况方法总结

    Linux查看CPU和内存使用情况:http://www.cnblogs.com/xd502djj/archive/2011/03/01/1968041.html 在做Linux系统优化的时候,物理内 ...

随机推荐

  1. 关于一些对map和整行读取文件操作

    public static void main(String[] args) { Map<String, String> map = new HashMap<String, Stri ...

  2. C&num;基础&lowbar;单例模式

    控制某个类型的实例数量-唯一一个 class Program { static void Main(string[] args) { test t1 = test.GetInstance(); tes ...

  3. Pair Project&colon;电梯控制程序

    12061160刘垚鹏 & 12061166宋天舒 1.1结对编程的优缺点结对编程相对于个人编程有很多优点.首先,督促作用,在讨论过程中能够很快投入工作,为了不耽误对方时间,我们会尽快完成各自 ...

  4. IQ测试

    1.4个人过桥,只能两两过桥,且只有一盏灯,必须有灯才能过桥,4个人过桥时间分别为1,2,5,10分钟,最短多少时间可以过桥? 答案:1和2先走,1再返回,花3分钟.5和10走,2回去,花了3+10+ ...

  5. cas&plus;tomcat&plus;shiro实现单点登录-2-部署cas server到tomcat

    目录 1.tomcat添加https安全协议 2.下载cas server端部署到tomcat上 3.CAS服务器深入配置(连接MYSQL) 4.Apache Shiro 集成Cas作为cas cli ...

  6. &period;NET 笔试分享

    最近一直在面试,每次面试前也不怎么准备,虽说碰到的题大部分都很简单的,但是在现场答题的时候由于自己紧张脑子就空了,一些题答的不是很好,所以只有每次回来的时候才能好好想想怎么答: 题大部分还是挺简单的, ...

  7. LeetCode&lpar;42&rpar;-Best Time to Buy and Sell Stock&lpar;卖股票&rpar;

    题目: Say you have an array for which the ith element is the price of a given stock on day i. If you w ...

  8. Docker for windows &colon; 安装Redis

    一.拉取Redis镜像 docker pull hub.c..com/library/redis: 二.创建并运行Redis docker run -d -it --name redis d4f259 ...

  9. 表达式语言 Expression Language

    JSP 2.0最重要的特性之一就是表达式语言 (EL),JSP用户可以用它来访问应用程序数据.由于 受到ECMAScript和XPath表达式语言的启发,EL也设计 成可以轻松地编写免脚本的JSP页面 ...

  10. 上传程序Dictionary 字典 哈希--多读一写锁ReaderWriterLock

    //上传程序Dictionary 字典 哈希 /// <summary> /// 车辆控制信息哈斯表,Key是终端号,Value是车辆信息控制对象 /// </summary> ...