Linux释放cache内存
Linux释放cache内存
/proc是个虚拟文档系统,我们能够通过对他的读写操作做为和kernel实体间进行通信的一种手段。也就是说能够通过修改/proc中的文档,来对当前kernel的行为做出调整。
那么我们能够通过调整/proc/sys/vm/drop_caches来释放内存。操作如下:
1、查看 /proc/sys/vm/drop_caches的值,默认为0:
- [root@server test]# cat /proc/sys/vm/drop_caches
- 0
2、手动执行sync命令:
- [root@server test]# sync
sync 命令运行 sync 子例程。假如必须停止系统,则运行 sync 命令以确保文档系统的完整性。sync 命令将任何未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文档。
3、将/proc/sys/vm/drop_caches值设为3
- [root@server test]# echo 3 > /proc/sys/vm/drop_caches
- [root@server test]# cat /proc/sys/vm/drop_caches
- 3
4、再来运行free命令:
- [root@server test]# free -m
- total used free shared buffers cached
- Mem: 249 66 182 0 0 11
- -/+ buffers/cache: 55 194
- Swap: 511 0 511
发现现在的used为66MB,free为182MB,buffers为0MB,cached为11MB。有效的释放了buffer和cache。
有关/proc/sys/vm/drop_caches的用法在下面进行了说明:
/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become
free.
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to
free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >
/proc/sys/vm/drop_caches.
Because this is a non-destructive operation and dirty objects
are not freeable, the user should run sync(8) first.
相关文章
- keychron K3 键盘和 Windows11 操作系统的笔记本电脑通过蓝牙配对出现问题的解决方案
- FPGA:组合逻辑电路的设计
- 【愚公系列】2023年01月 .NET CORE工具案例-SharpConfig配置文件读取库
- Webpack提取页面公共资源
- 【愚公系列】2023年01月 .NET CORE工具案例- Magick.NET神级图片和视频操作库
- 生信星球day7-毽子
- RealWorldCtf2023-The_cult_of_8_bit详解
- nesbot/carbon 日期时间处理扩展包
- phpoffice/phpexcel 导出Excel表格数据
- Windows 系统 PhpStorm 2020无限试用30天
- 微擎安装模块时提示 Failed to connect to we7.rewlkj.com port 80: Timed out
- Sketch Fashion for mac(服装设计软件) v1.2.5中文版
- vue.js客服系统实时聊天项目开发(四)引入iconfont图标代码
- vue.js客服系统实时聊天项目开发(五)flex布局实现输入框区域
- SSH 公钥免密登录
- TP6.0 自定义日志驱动
- 【虹科新闻】虹科被评为“2022年广东省‘专精特新’中小企业”
- 【好玩儿的Docker项目】10分钟部署一个类似知乎的开源问答平台——Answer
- MLBSP - 我的世界轻量化基础开服包
- 【好玩儿的Docker项目】Hexo在线管理+Butterfly主题+自部署Twikoo评论系统