惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
Scott Helme
Scott Helme
Google Online Security Blog
Google Online Security Blog
L
LINUX DO - 最新话题
O
OpenAI News
S
Secure Thoughts
Cisco Talos Blog
Cisco Talos Blog
Forbes - Security
Forbes - Security
V
Visual Studio Blog
有赞技术团队
有赞技术团队
Jina AI
Jina AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Troy Hunt's Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
Schneier on Security
雷峰网
雷峰网
The Cloudflare Blog
量子位
Last Week in AI
Last Week in AI
T
Tor Project blog
V
Vulnerabilities – Threatpost
C
Cisco Blogs
B
Blog RSS Feed
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
G
GRAHAM CLULEY
MyScale Blog
MyScale Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Schneier on Security
Schneier on Security
Martin Fowler
Martin Fowler
Help Net Security
Help Net Security
J
Java Code Geeks
人人都是产品经理
人人都是产品经理
G
Google Developers Blog
S
Security Affairs
A
Arctic Wolf
T
Tenable Blog
PCI Perspectives
PCI Perspectives
Spread Privacy
Spread Privacy
AI
AI
L
LangChain Blog
Latest news
Latest news
博客园 - 叶小钗
博客园 - Franky
T
Threatpost
MongoDB | Blog
MongoDB | Blog
Hugging Face - Blog
Hugging Face - Blog

博客园 - ricks

解决VS Code安装golang相关插件失败问题 努力就会成功(转自左耳朵耗子) 最全科普!你一定要了解的NB-IoT LTE - NAS 驻网流程概括 PLMN概念和应用设置 3GPP R14中的6大NB-IoT增强技术 与程序员相关的CPU缓存知识 IoT协议LwM2M MQTT与CoAP 别让自己“墙”了自己(转自耗子叔) NB-IoT的介绍最终版 !看明白了吗?(转自 top-iot) C语言函数sscanf()的用法 GPRS骨干网逻辑结构 GSM与GPRS的区别 SA vs NSA 打造高效的工作环境 – SHELL 篇 linux下怎么清理缓存 iptables禁止某个mac地址上网 使用iptables基于MAC地址进行访控 iptables的MAC地址过滤
清理系统缓存
ricks · 2019-01-30 · via 博客园 - ricks

清理系统缓存
当服务器内存使用率高达90%以上时,且有较大耗内存操作时,可以考虑把系统的垃圾内存清理掉。方法如下

 echo 3 > /proc/sys/vm/drop_caches

~ # free
      total    used       free     shared      buffers
Mem:   155728    119840      35888      176       28
-/+ buffers:        119812      35916
Swap: 0 0 0
~ # echo 3 > /proc/sys/vm/drop_caches
~ # free
    total    used       free   shared   buffers
Mem: 155728   65828   89900   176      0
-/+ buffers:        65828   89900
Swap: 0 0 0

 -----------------------------------------------------------

哪里有过大?cached 和 buffers 占据 available 部分中的绝大部分是正常的。你说你的内存,free 着就是什么用处都没有,但你以为那些部分就不需要通电、刷新吗?

cached 通常属于 available 部分(该数据 3.14 内核之后提供,procps-ng 较新版本也显示),也就是可用内存。什么时候程序需要了,什么时候拿去用。暂时不需要?那我从磁盘那个慢到死的家伙里好不容易读出来的数据先留着,指不定用户还要用到呢。

有兴趣可以 echo 3 到那什么文件/proc/sys/vm/drop_caches清空一下这些部分,然后 ls /usr/lib 试试。然后立即再执行一次,是不是有缓存之后就快多了?

至于 sync 命令。它和 cached 有关,但是不是你所想的那个功能。它的功能是,把脏页写回磁盘,也就是把修改过的数据还没写到磁盘的数据写到磁盘上。因为内核会延迟提交,每次提交多积累一些数据,以提高效率、降低延迟。没有使用的必要,只会让系统卡一下而已。