转自 :http://blog.sina.com.cn/s/blog_4bb52a1601017ltn.html

这位朋友写的很详细

fengwei@linuxserver ~]$ free -m

total       used       free     shared    buffers     cached

Mem:        15656      12163       3493         0         19      10136

-/+ buffers/cache:       2008      13648

Swap:        18047        181      17866

[fengwei@linuxserver ~SiRNA]$ su root

paasword:

[root@linuxserver ~]# cat /proc/sys/vm/drop_caches

0

[root@linuxserver ~]# sync

[root@linuxserver ~]# echo 1 >/proc/sys/vm/drop_caches

[root@linuxserver ~]# free -m

total       used       free     shared    buffers     cached

Mem:        15656       2016    13640         0          1        245

-/+ buffers/cache:       1768      13888

Swap:        18047        181      17866

手动释放缓存

/proc是一个虚拟文件系统,我们可以通过对它的读写操作做为与kernel实体间进行通信的一种手段。也就是说可以通过修改/proc中的文件,来对 当前kernel的行为做出调整。那么我们可以通过调整/proc/sys/vm/drop_caches来释放内存。操作如下:

引用[root@server test]# cat /proc/sys/vm/drop_caches

0

首先,/proc/sys/vm/drop_caches的值,默认为0。

引用[root@server test]# sync

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

引用[root@server test]# echo 3 > /proc/sys/vm/drop_caches

[root@server test]# cat /proc/sys/vm/drop_caches

3

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

引用[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

再来运行free命令,会发现现在的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;

tofree 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 first.

本文转自aaa超超aaa 51CTO博客,原文链接:http://blog.51cto.com/10983441/1762951

手动释放linux服务器内存相关推荐

  1. linux服务器清理内存,释放Linux服务器内存

    在服务器运行一段时间后,你会发现系统的内存越来越小,有的朋友会担心了,想办法释放内存,提高运行速度: 其实这是服务器申请的一个缓存,服务器发现内存不足时,会自动清理缓存,释放内存,然后继续增大缓存,内 ...

  2. linux内存过高怎样清理,如何处理Linux服务器内存过高?

    作者:张岩峰,转载请注明出处     笔名:云烟旧梦 51CTO课程地址:https://edu.51cto.com/lecturer/12750547.html    Linux技术交流群:1127 ...

  3. linux服务器128g内存,如何处理Linux服务器内存过高?

    作者:张岩峰,转载请注明出处     笔名:云烟旧梦 51CTO课程地址:https://edu.51cto.com/lecturer/12750547.html    Linux技术交流群:1127 ...

  4. 【Linux】解决Linux服务器内存不足问题

    [Linux]解决Linux服务器内存不足问题 参考文章: (1)[Linux]解决Linux服务器内存不足问题 (2)https://www.cnblogs.com/haochuang/p/1191 ...

  5. 【收藏】如何查看linux服务器内存使用情况

    如何查看linux服务器内存使用情况 https://www.cnblogs.com/hanmk/p/10556989.html [root@m-0 ~]# ps -eo pmem,pcpu,rss, ...

  6. 如何释放linux的内存

    你们知道怎么释放linux的内存吗不知道的话跟着学习啦小编一起来学习怎么释放linux的内存. 释放linux的内存的步骤 Linux下操作频繁时,物理内存会被快速用完,当操作结束后,物理内存没有被正 ...

  7. 命令查看Linux服务器内存、CPU、显卡、硬盘使用情况

    命令查看Linux服务器内存.CPU.显卡.硬盘使用情况 查看内存使用情况 使用命令:free -m 大致结果类似下图: 内存占用情况 参数解释: Mem行(单位均为M): total:内存总数 us ...

  8. 查看linux服务器内存使用情况,不够时创建Swap、手动 cached

    2019独角兽企业重金招聘Python工程师标准>>> 如何知道系统的内存使用情况: 在Linux下查看内存我们一般用free命令: [root@scs-2 tmp]# free t ...

  9. linux服务器内存占用太高-释放内存

    修改/proc/sys/vm/drop_caches,释放Slab占用的cache内存空间(参考drop_caches的官方文档): Writing to this will cause the ke ...

最新文章

  1. 解决-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variabl
  2. 搜索---广度优先遍历、深度优先遍历、回溯法
  3. mysql创建多实例,mysql 单服务器创建多实例
  4. LeetCode(637)——二叉树的层平均值(JavaScript)
  5. mysql将一个表的字段更新到另一个表中
  6. python创意小作品-全国青少年创意编程与智能设计大赛Python创意编程比赛
  7. Webpack4 学习笔记一初探Webpack
  8. Spring框架中constructor-arg与property理解
  9. OperationQueue与属性maxConcurrentOperationCount的那些事
  10. Scan2CAD pro中文版
  11. 学习笔记(01):通俗易懂的Bootstrap视频课程(适合初学者的教程)-图标、下拉菜单、按钮组...
  12. 逐向双碳:绿色计算的误区与正确打开方式
  13. Weclome to Thm-V九维空间
  14. php调取微信接口token上限,解决微信access_token上限问题
  15. VMware安装window8系统
  16. android扫码二维码识别二维码
  17. 面试自我介绍范文(30篇)
  18. vue获得腾讯坐标拾取器
  19. 华纳云:ddos攻击怎么防?防御ddos的几种方法
  20. uniapp使用云开发做excel数据导出的坑

热门文章

  1. uc3842改可调电源教程_《学习笔记》--DC/DC电源电路设计实例
  2. mysql 重置密码 win_window下重置mysql用户密码
  3. python中logging模块详解_python logging日志模块详解
  4. sublime text3 选词及批量操作、设置书签快捷键、打开的插件view in browser
  5. 通过流程构建组织的【个人能力】和【团队能力】
  6. 一个API方式存取日志文件的模块[VB]
  7. VB在菜单上增加图标
  8. 找不出破绽!斯坦福等新研究:随意输入文本,改变视频人物对白,逼真到让作者害怕...
  9. 帮中国修长城前,英特尔还用AI追踪北极熊、保护鲸鱼
  10. 宽凳科技,这是前百度外卖董事长刘骏的新征途