linux swap理解-为什么linux有足够的内存还进行swap
来源:互联网 发布:纺织erp软件 编辑:程序博客网 时间:2024/06/04 23:34
Linux starts swapping before the RAM is filled up. This is done to improve performance and responsiveness:
Performance is increased because sometimes RAM is better used for disk cache than to store program memory. So it's better to swap out a program that's been inactive for a while, and instead keep often-used files in cache.
Responsiveness is improved by swapping pages out when the system is idle, rather than when the memory is full and some program is running and requesting more RAM to complete a task.
Swapping does slow the system down, of course — but the alternative to swapping isn't not swapping, it's having more RAM or using less RAM.
翻译:Linux在物理内存用完之前使用swap,,这样有助于提高系统性能和响应能力1 性能可以提升的原因是:一些内存放磁盘缓存比方内存更合适。所以,最好交换出暂时不使用的内存,而把经常使用的文件放内存里面
2 提升响应能力通过,当系统空闲的时候swap page out,而不是当内存忙的时候,正在执行程序的时候执行swap
swaping确实会是系统性能下降,当然,通过swap可以有更多的可用内存
如何在有内存可用的时候,不使用swap呢?
This behaviour can be configured by setting the value of /proc/sys/vm/swappiness
. The default value is 60, setting it to 0 means “never use swap when there is still RAM left“ and 100 is swapping out memory as soon as possible.
To change the value temporarily (lost on reboot):
sudo sysctl vm.swappiness=10
To change the value permanently: Edit the file /etc/sysctl.conf
as root (e.g. sudo nano /etc/sysctl.conf
) and change the line vm.swapiness=...
to the desired value.
There has been some debate on whether swapping out with free memory available is good or bad, but the Ubuntu help does indeed recommend a value of 10 for Desktop systems:https://help.ubuntu.com/community/SwapFaq
centos swappiness配置的路径 /proc/sys/vm/swappiness
为什么不建议关闭swap
It is NOT recommended to turn off swap even if you have enough memory. If your server needs more memory and it did not get it, it will crash. However, this can be prevented (to some extent) when you have a swap area.
Yes, your server performance will degrade when using swap, but at least it will be operational and accessible. Then, you can plan for adding more memory when needed if your server starts using swap.
I found this page talking about swap. Have a look at 3rd section.
Instead of turning off swap, you can control the swapiness.
参考
http://unix.stackexchange.com/questions/2658/why-use-swap-when-there-is-more-than-enough-ram
swap知识 https://help.ubuntu.com/community/SwapFaq
http://linux.cloudibee.com/2007/11/linux-performance-tuning-vm-swappiness/
- linux swap理解-为什么linux有足够的内存还进行swap
- 释放linux的swap内存
- linux 添加swap内存
- linux SWAP大小与内存的关系
- Linux内存使用和swap的关系
- LINUX的SWAP
- Linux的swap分区
- Linux Swap的基本原理
- Linux的swap分区
- Linux内存高级 [swap/buffer]
- Linux内存中Swap机制
- Linux swap
- linux swap
- linux swap
- Linux---Swap
- 【Linux】为什么linux要用swap分区?
- linux的swap的扩展
- 个人对Linux交换分区(swap)的理解
- java中的类!
- ThinkPHP学习(三)配置PHP5支持MySQL,连接MySQL数据库
- ORACLE 日期相关函数
- 批处理判断变量值是否为空的终极方法
- 如何调试makefile变量
- linux swap理解-为什么linux有足够的内存还进行swap
- linux驱动学习-4th
- 数据结构——左高树(C语言)
- Android Phone模块 一
- java jdom解析xml格式字符串
- JDK1.7新特性
- 易经六十四卦详解
- 【安卓笔记】自定义view之组合控件
- java的fuction!