Chinaunix首页 | 论坛 | 博客
  • 博客访问: 347591
  • 博文数量: 38
  • 博客积分: 1289
  • 博客等级: 中尉
  • 技术积分: 533
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-10 22:30
个人简介

Good Good Study. Day Day Up.

文章分类

全部博文(38)

文章存档

2018年(1)

2016年(3)

2015年(12)

2014年(7)

2013年(10)

2012年(5)

分类: 系统运维

2015-09-06 11:02:18

很多人在Linux系统里面看到free命令的结果中cached占了很大一部分内存,总在纠结要不要手工清理一下缓存。其实绝大部分情况下是没有必要这样做的。

从RedHat的官方文档里面可以看到,当应用程序(例如数据库)需要更多内存的时候,系统会自动释放cache,不会跟应用程序抢内存,所以cache可以认为是可用内存的一部分。参考:
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/5/html-single/Tuning_and_Optimizing_Red_Hat_Enterprise_Linux_for_Oracle_9i_and_10g_Databases/index.html#sect-Oracle_9i_and_10g_Tuning_Guide-Memory_Usage_and_Page_Cache-Checking_the_Memory_Usage
 
$ free
              total       used        free    shared    buffers    cached
Mem:        4040360    4012200       28160         0     176628   3571348
-/+ buffers/cache:      264224     3776136
Swap:       4200956      12184     4188772
 
In this example the total amount of available memory is 4040360 KB. 264224 KB are used by processes and 3776136 KB are free for other applications. Do not get confused by the first line which shows that 28160KB are free! If you look at the usage figures you can see that most of the memory use is for buffers and cache. Linux always tries to use RAM to speed up disk operations by using available memory for buffers (file system metadata) and cache (pages with actual contents of files or block devices). This helps the system to run faster because disk information is already in memory which saves I/O operations. If space is needed by programs or applications like Oracle, then Linux will free up the buffers and cache to yield memory for the applications. If your system runs for a while you will usually see a small number under the field "free" on the first line.
 
另外一个文档里面也提到,不建议手工清理cache,因为有可能影响数据库的性能。参考:
/>
阅读(3340) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~