您正在使用 IPV4 [18.222.148.124] 访问本站,您本次已经查看了 1 页
用户名: 密 码: 验证码:     用QQ登录本站
首页 软件 编程 笑话 知识 公告 台风 日历 计算器
[公益]保护绿色环境,构建和谐社会       悟空收录网      

【腾讯云】2核2G4M云服务器新老同享99元/年,续费同价      
[公益] 地球是我家,绿化靠大家      
2024年 劳动节 002
2024年 端午节 042
2025年 元 旦 247
2025年 春 节 275
 
您现在的位置:首页 >> Linux >> 内容
本类新增
本类热门
linux 内存清理/释放命令总结
内容摘要: 1.清理前内存使用情况free-m2.开始清理echo1/proc/sys/vm/drop_caches3.清理后内存使用情况free-m4.完成!查看内存条数命令:dmidecode|grep-A16'MemoryDevice$'#sync#echo1/proc/sys/vm/drop_cachesecho2/proc/sys/vm/drop_caches......
1.清理前内存使用情况

free-m

2.开始清理

echo1>/proc/sys/vm/drop_caches

3.清理后内存使用情况

free-m

4.完成!

查看内存条数命令:

dmidecode|grep-A16"MemoryDevice$"

#sync

#echo1>/proc/sys/vm/drop_caches

echo2>/proc/sys/vm/drop_caches

echo3>/proc/sys/vm/drop_caches

cache释放:

Tofreepagecache:

echo1>/proc/sys/vm/drop_caches

Tofreedentriesandinodes:

echo2>/proc/sys/vm/drop_caches

Tofreepagecache,dentriesandinodes:

echo3>/proc/sys/vm/drop_caches

说明,释放前最好sync一下,防止丢数据。

因为LINUX的内核机制,一般情况下不需要特意去释放已经使用的cache。这些cache起来的内容可以增加文件以及的读写速度。

先说下free命令怎么看内存

[root@yuyiiproc]#free

totalusedfreesharedbufferscached

Mem:5155882954522201360206064040

-/+buffers/cache:229352286236

Swap:682720112682608

其中第一行用全局角度描述系统使用的内存状况:

total——总物理内存

used——已使用内存,一般情况这个值会比较大,因为这个值包括了cache+应用程序使用的内存

free——完全未被使用的内存

shared——应用程序共享内存

buffers——缓存,主要用于目录方面,inode值等(ls大目录可看到这个值增加)

cached——缓存,用于已打开的文件

note:

total=used+free

used=buffers+cached(maybeaddsharedalso)

第二行描述应用程序的内存使用:

前个值表示-buffers/cache——应用程序使用的内存大小,used减去缓存值

后个值表示+buffers/cache——所有可供应用程序使用的内存大小,free加上缓存值

note:

-buffers/cache=used-buffers-cached

+buffers/cache=free+buffers+cached

第三行表示swap的使用:

used——已使用

free——未使用

手动执行sync命令(描述:sync命令运行sync子例程。如果必须停止系统,则运行sync命令以确保文件系统的完整性。sync命令将所有未写的系统缓冲区写到磁盘中,包含已修改的i-node、已延迟的块I/O和读写映射文件)

[root@servertest]#echo3>/proc/sys/vm/drop_caches

[root@servertest]#cat/proc/sys/vm/drop_caches

!将/proc/sys/vm/drop_caches值设为3

有关/proc/sys/vm/drop_caches的用法在下面进行了说明

/proc/sys/vm/drop_caches(sinceLinux2.6.16)

Writingtothisfilecausesthekerneltodropcleancaches,

dentriesandinodesfrommemory,causingthatmemorytobecome

free.

Tofreepagecache,useecho1>/proc/sys/vm/drop_caches;to

freedentriesandinodes,useecho2>/proc/sys/vm/drop_caches;

tofreepagecache,dentriesandinodes,useecho3>

/proc/sys/vm/drop_caches.

Becausethisisanon-destructiveoperationanddirtyobjects

版权声明:本内容来源于网络,如有侵犯您的版权,请联系站长,本站收到您的信息后将及时处理。
上一篇:Linux 查看内存使用情况的几种方法汇总

 

下一篇:linux添加删除路由的技巧

发布日期:2024/2/20
手机扫二维码直达本页
发布时间:14:35:27
点  击:18
录  入:哲哲
相关文章
Baidu
YiJiaCMS 7.3.8 build231228(MSSQL) 闽ICP备05000814号-1
本空间由腾讯云(轻量应用服务器)提供,奇安信网站卫士提供加速防护
运行时间载入中.....