Linux 控制 配置 减少 交换分区 SWAP 虚拟内存使用
2016-04-10 20:57
603 查看
对于某些大型应用来说,SWAP 严重影响性能,尽可能避免使用:
The Linux kernel provides a tweakable setting that controls how often the swap file is used, called swappiness
A swappiness setting of zero means that the disk will be avoided unless absolutely necessary (you run out of memory), while a swappiness setting of 100 means that programs will be swapped to disk almost instantly.
Ubuntu system comes with a default of 60, meaning that the swap file will be used fairly often if the memory usage is around half of my RAM. You can check your own system's swappiness value by running:
As I have 4 GB of RAM, so I'd like to turn that down to 10 or 15. The swap file will then only be used when my RAM usage is around 80 or 90 percent. To change the system swappiness value, open
Reboot for the change to take effect
You can also change the value while your system is still running
you can also clear your swap by running
To calculate your swap Formula
so total is 3950 / 100 = 39.5 * 10 = 395
so what it mean is that when 10 % 395 MB of ram left then it start using swapiness
https://en.wikipedia.org/wiki/Swappiness
http://stackoverflow.com/questions/10853074/swappiness-in-jvm
The Linux kernel provides a tweakable setting that controls how often the swap file is used, called swappiness
A swappiness setting of zero means that the disk will be avoided unless absolutely necessary (you run out of memory), while a swappiness setting of 100 means that programs will be swapped to disk almost instantly.
Ubuntu system comes with a default of 60, meaning that the swap file will be used fairly often if the memory usage is around half of my RAM. You can check your own system's swappiness value by running:
one@onezero:~$ cat /proc/sys/vm/swappiness 60
As I have 4 GB of RAM, so I'd like to turn that down to 10 or 15. The swap file will then only be used when my RAM usage is around 80 or 90 percent. To change the system swappiness value, open
/etc/sysctl.confas root. Then, change or add this line to the file:
vm.swappiness = 10
Reboot for the change to take effect
You can also change the value while your system is still running
sysctl vm.swappiness=10
you can also clear your swap by running
swapoff -aand then
swapon -aas root instead of rebooting to achieve the same effect.
To calculate your swap Formula
free -m (total) / 100 = A A * 10 root@onezero:/home/one# free -m total used free shared buffers cached Mem: 3950 2262 1687 0 407 952 -/+ buffers/cache: 903 3047 Swap: 1953 0 1953
so total is 3950 / 100 = 39.5 * 10 = 395
so what it mean is that when 10 % 395 MB of ram left then it start using swapiness
https://en.wikipedia.org/wiki/Swappiness
http://stackoverflow.com/questions/10853074/swappiness-in-jvm
相关文章推荐
- Linux jar包 后台运行
- Linux jar包 后台运行
- linux进程调度策略
- linux 《vmware下克隆的centos无法配置固定ip》
- linux内核分析 第七周读书笔记
- linux ssh -l 命令运用
- Centos7 Ansible安装
- CentOS 6的系统启动流程
- lab7:Linux内核如何装载和启动一个可执行程序
- Linux学习(3)——文件管理命令
- 十款最常见的Linux发行版
- 苹果后门、微软垄断与Linux缺位
- Linux 下編輯 PDF 檔的工具
- Linux内核分析——可执行程序的装载
- vnc服务器的搭建
- NUll
- centos mysql更改数据存放位置datadir(NTF格式硬盘)
- Linux命令整合之alias
- Linux内核如何装载和启动一个可执行程序
- Linux中用户,组及权限的概念及相关命令