Linux操作系统如何释放cache内存

来源:asp之家 时间:2009-09-20 20:18:00 

/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; 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.

标签:linux,操作系统,内存
0
投稿

猜你喜欢

  • vsFTP服务器的维护

    2009-12-23 19:03:00
  • Windows下Apache与Tomcat的整合

    2008-07-21 12:20:00
  • adsense有点击次数却没有收入?

    2008-08-06 20:21:00
  • SSH命令详解

    2009-11-19 12:08:00
  • 百度智能手机输入法v1.0 Beta下载

    2009-12-02 11:26:00
  • 使用web.config显示GoDaddy的windows主机的详细错误

    2010-04-08 12:46:00
  • SupeSite7.0模板样式解析之日志篇

    2009-09-18 12:45:00
  • Mashup!让搜索引擎显示缩略图

    2007-10-29 12:01:00
  • 帝国CMS与PHPCMS对比(四):碎片功能分析

    2011-08-26 12:57:07
  • 使用Linux系统架设安全的网关

    2008-10-13 18:09:00
  • 屏蔽掉Google Adsense中单价极低的广告商

    2009-02-04 13:03:00
  • 齐唐网站运营日记之网站运营篇

    2008-12-15 10:58:00
  • 如何设置GoDaddy-Linux主机的高级目录权限

    2010-04-26 12:49:00
  • 如何在本地同时架设ASP和PHP网站运行环境

    2008-05-27 12:42:00
  • Google AdSense国内测试电子银行转账付款

    2009-03-19 18:26:00
  • 用户体验指导思想 易用友好 把用户当傻瓜

    2008-12-03 07:37:00
  • 必须了解的五个服务器基础问题

    2009-01-13 16:50:00
  • 20个实用的WordPress SQL查询

    2011-03-31 18:00:00
  • 谷歌趋势和百度指数对比

    2008-06-21 16:36:00
  • Apache+Proftpd虚拟主机的安全问题

    2009-08-18 10:42:00
  • asp之家 网站运营 m.aspxhome.com