注意:首先我们需要使用sync指令,将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文件。否则在释放缓存的过程中,可能会丢失未保存的文件。

的值可以为0~3之间的任意数字,代表着不同的含义:

0 – 不释放

1 – 释放页缓存

2 – 释放dentries和inodes

3 – 释放所有缓存
[root@ok Desktop]# cat /proc/sys/vm/drop_caches
0
[root@ok Desktop]# file /proc/sys/vm/drop_caches
/proc/sys/vm/drop_caches: empty
[root@ok Desktop]# echo 1 >/proc/sys/vm/drop_caches
[root@ok Desktop]# free -h
total used free shared buffers cached
Mem: 11G 966M 10G 53M 392K 161M
-/+ buffers/cache: 804M 10G
Swap: 3.6G 0B 3.6G

查看内存条个数:

[root@ok Desktop]# dmidecode | grep -A16 "Memory Device$"
Memory Device
Array Handle: 0x0005
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 8192 MB
Form Factor: SODIMM
Set: None
Locator: ChannelA-DIMM0
Bank Locator: BANK 0
Type: DDR3
Type Detail: Synchronous
Speed: 1600 MHz
Manufacturer: Kingston
Serial Number: 7633D911
Asset Tag: None
Part Number: KHX1600C9S3L/8G
--
Memory Device
Array Handle: 0x0005
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 4096 MB
Form Factor: SODIMM
Set: None
Locator: ChannelB-DIMM0
Bank Locator: BANK 2
Type: DDR3
Type Detail: Synchronous
Speed: 1600 MHz
Manufacturer: Samsung
Serial Number: 20A9C496
Asset Tag: None
Part Number: M471B5173DB0-YK0

清除pagecache:

[root@ok ~]# sync
[root@ok ~]# sysctl -w vm.drop_caches=1
vm.drop_caches = 1
[root@ok ~]# free -h
total used free shared buffers cached
Mem: 11G 1.1G 10G 82M 412K 192M
-/+ buffers/cache: 980M 10G
Swap: 3.6G 0B 3.6G

清空 dentries 和 inodes:

[root@ok ~]# sync
[root@ok ~]# sysctl -w vm.drop_caches=2
vm.drop_caches = 2
[root@ok ~]# free -h
total used free shared buffers cached
Mem: 11G 1.2G 10G 79M 5.7M 224M
-/+ buffers/cache: 959M 10G
Swap: 3.6G 0B 3.6G

清空所有缓存 pagecache、dentries 和 inodes):

[root@ok ~]# sync
[root@ok ~]# sysctl -w vm.drop_caches=3
vm.drop_caches = 3
[root@ok ~]# free -h
total used free shared buffers cached
Mem: 11G 1.1G 10G 101M 1.5M 210M
-/+ buffers/cache: 956M 10G
Swap: 3.6G 0B 3.6G

最新文章

  1. 用SignalR 2.0开发客服系统[系列1:实现群发通讯]
  2. visual studio 编辑窗口 设置固定选项卡 使窗口选项卡多行显示
  3. 一、Daily Scrum Meeting【Alpha】------Clover
  4. AJAX 与 MySQL
  5. hystrix-turbine 监控的使用
  6. HTML DOM Document
  7. QTP实现功能测试的时候,当新版本的页面都改变了,应该如何解决
  8. 不重启使XP环境变量生效
  9. SSH架构简单总结
  10. Thinking in java——Generics
  11. SharePoint 2010 Ribbon的实现
  12. JS如何得到Repeater中TextBox控件的值
  13. 整理:GET与POST的区别
  14. The method replace(int, Fragment, String) in the type FragmentTransaction is not applicable for the arguments (int, SettingFragment, String)
  15. Apriori算法
  16. 【python】问题汇总
  17. deepin 桌面突然卡死
  18. Flink – WindowedStream
  19. ss linux终端配置
  20. nginx配置详解(转)

热门文章

  1. ORDER BY,GROUP BY 和DI STI NCT 优化
  2. 对 getaddrinfo Android 返回错误 EAI_BADFLAGS
  3. OpenMP 中的线程任务调度
  4. Django admin管理
  5. 深度Linux Deepin系统安装教程使用体验
  6. 要点Java20 java.util.Collections
  7. (剑指Offer)面试题41:和为s的连续正数序列
  8. xmpp 服务器配置 open fire for windows 及 spark 测试
  9. quartz.net持久化和集群【转】
  10. 手动脱UPX 壳实战