/proc/sys/vm/drop_caches 清理缓存
1. 使用方法
/proc/sys/vm/drop_caches默认是0
# echo 1 > /proc/sys/vm/drop_caches; free pagecache, use
# echo 2 > /proc/sys/vm/drop_caches; free dentries and inodes
# echo 3 > /proc/sys/vm/drop_caches; free pagecache, dentries and inodes
注意:使用之前需要先sync,将缓存刷到磁盘中。
2. 实验
单位:MB # free -m
total used free shared buff/cache available
Mem: 79
Swap:
# cp /etc/* /mytest/
# free -m
total used free shared buff/cache available
Mem: 1825 382 1341 8 1412
Swap: 0 0 0 过一段时间: # free -m
total used free shared buff/cache available
Mem: 1825 382 1341 8 1412
Swap: 0 # cat /proc/sys/vm/drop_caches
0 # sync # echo 3 > /proc/sys/vm/drop_caches
# free -m
total used free shared buff/cache available
Mem: 1825 382 1405 8 1413
Swap:
3. 写个脚本做这个事情
# cat cleanup_cache.sh
#!/bin/sh
# drop_caches for every mins drop_caches() {
echo "Drop caches."
sync
echo > /proc/sys/vm/drop_caches &
return
} while true; do
sleep
drop_caches
done exit
4. 结论
Linux内核默认保持drop_cache的值是0,不建议经常修改它。
/proc/sys/vm/drop_caches 清理缓存的更多相关文章
- Linux下清理内存和Cache方法 /proc/sys/vm/drop_caches
Linux下清理内存和Cache方法 /proc/sys/vm/drop_caches 频繁的文件访问会导致系统的Cache使用量大增 $ free -m total used free shared ...
- [转]手工释放linux内存——/proc/sys/vm/drop_caches
另一篇:http://www.linuxfly.org/post/320/ 1.清理前内存使用情况 free -m 2.开始清理 echo 1 > /proc/sys/vm/drop_ca ...
- linux内存——/proc/sys/vm/drop_caches
原贴:http://www.linuxfly.org/post/320/ http://blog.csdn.net/chinalinuxzend/article/category/265273/2 ...
- 手工释放linux内存——/proc/sys/vm/drop_caches
--手工释放linux内存——/proc/sys/vm/drop_caches 总有很多朋友对于Linux的内存管理有疑问,之前一篇日志似乎也没能清除大家的疑虑.而在新版核心中,似乎对这个问题提供了新 ...
- 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 ...
- (转)手工释放linux内存——/proc/sys/vm/drop_cache
linux的内存查看: [root@localhost 0.1.0]# free -m total used free shared ...
- 手工释放linux内存------/proc/sys/vm/drop_cache
当在Linux下频繁存取文件后,物理内存会很快被用光,当程序结束后,内存不会被正常释放,而是一直作为caching.这个问题,貌似有不少人在问,不过都没有看到有什么很好解决的办法.那么我来谈谈这个问题 ...
- /proc/sys/shm/drop_caches
author:skate time:2012/02/22 手工释放linux内存--/proc/sys/vm/drop_cache 转载一篇文章 linux的内存查看: [root@localhost ...
- /proc/sys/vm man手册
Manual page proc(5) line 1967 (press h for help or q to quit) /proc/sys/vm This directory contains f ...
随机推荐
- 第五章 [BX]和loop指令
5.1 [bx] [bx]是什么 和 [0] 有些类似,[0] 表示内存单元,它的偏移地址是 0. 例如: mov ax, [0] 内存以字节为单位:ax以字(16bit = 2Byte)为单位:al ...
- LeetCode--175--组合两个表
问题描述: 表1: Person +-------------+---------+ | 列名 | 类型 | +-------------+---------+ | PersonId | int | ...
- codeforces 497b// Tennis Game// Codeforces Round #283(Div. 1)
题意:网球有一方赢t球算一场,先赢s场的获胜.数列arr(长度为n)记录了每场的胜利者,问可能的t和s. 首先,合法的场景必须: 1两方赢的场数不一样多. 2赢多的一方最后一场必须赢. 3最后一场必须 ...
- Python基础--文件操作和集合
这篇博客来说一下python对文件的操作. 对文件的操作分三步: 1.打开文件获取文件的句柄,句柄就理解为这个文件 2.通过文件句柄操作文件 3.关闭文件. 现有以下文件file.txt: 我们哭了 ...
- codefroces 450B矩阵快速幂
找出递推关系式就好了 (fi+1)=(1 -1)(fi ) ( fi)=(1 0)(fi-1) 不会打矩阵将就着看吧... 这是第一道矩阵快速幂.细节还是有很多没注意到的 本来想看挑战写 ...
- MVC,重写AuthorizeAttribute实现自己的权限验证(一)
我们要实现下面的效果,某个controller,只允许某几个角色访问(admin,user,document controller) [MyAuthorize(Roles = "Admin, ...
- app.jsNodejs启动测试服务
'use strict'; var express = require('express');var app = express('');var fs = require('fs'); app.get ...
- kettle 发邮件带附件
新建一个job,主要用到的组件有两个,如下图: 首先点击下图的文件,选择你要做为邮件附件的文件.选完后会在前辈的文件.目录中显示.然后点击增加,会下面文件列表中显示已经添加的文件(涂黄色的部分) 按下 ...
- Oracle 等待事件 db file sequential read
db file sequential read-数据文件顺序读取 等待事件: "db file sequential read" Reference Note (文档 ID 345 ...
- DBLookupComboBox 的初始值
http://www.yourdelphi.com/topic_234544_e6b7.htm 试下在form的oncreate中加入 dblookupcombobox1.keyvalue:=tabl ...