linux 清内存
2024-08-29 02:25:59
注意:首先我们需要使用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
最新文章
- 用SignalR 2.0开发客服系统[系列1:实现群发通讯]
- visual studio 编辑窗口 设置固定选项卡 使窗口选项卡多行显示
- 一、Daily Scrum Meeting【Alpha】------Clover
- AJAX 与 MySQL
- hystrix-turbine 监控的使用
- HTML DOM Document
- QTP实现功能测试的时候,当新版本的页面都改变了,应该如何解决
- 不重启使XP环境变量生效
- SSH架构简单总结
- Thinking in java——Generics
- SharePoint 2010 Ribbon的实现
- JS如何得到Repeater中TextBox控件的值
- 整理:GET与POST的区别
- The method replace(int, Fragment, String) in the type FragmentTransaction is not applicable for the arguments (int, SettingFragment, String)
- Apriori算法
- 【python】问题汇总
- deepin 桌面突然卡死
- Flink – WindowedStream
- ss linux终端配置
- nginx配置详解(转)