Linux 控制 配置 减少 交换分区 SWAP 虚拟内存使用
对于某些大型应用来说,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:
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.conf as 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 -a and then swapon -a as 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 控制 配置 减少 交换分区 SWAP 虚拟内存使用的更多相关文章
- Linux 交换分区swap
Linux 交换分区swap 一.创建和启用swap交换区 如果你的服务器的总是报告内存不足,并且时常因为内存不足而引发服务被强制kill的话,在不增加物理内存的情况下,启用swap交换区作为虚拟内存 ...
- Linux_交换分区SWAP
一.交换分区SWAP 1️⃣:交换分区SWAP就是LINUX下的虚拟内存分区,它的作用是在物理内存使用完之后,将磁盘空间(也就是SWAP分区)虚拟成内存来使用. 2️⃣:交换分区一般指定虚拟内存的大小 ...
- Linux交换分区swap
一.SWAP 说明 1.1 SWAP 概述 当系统的物理内存不够用的时候,就需要将物理内存中的一部分空间释放出来,以供当前运行的程序使用.那些被释放的空间可能来自一些很长时间没有什么操作的程序,这些被 ...
- linux两种增加交换分区(swap)的方法
在安装Oracle后,为使Oracle流畅运行,需要手动增加linux的交换分区(相当于Windows下的虚拟内存)的大小,本文介绍两种增加交换分区(swap)的方法. 第一种方法:新建分区 1.fd ...
- linux(centos8): 临时关闭/永久关闭交换分区swap?
一,为什么要关闭swap? 1,swap的用途? swap 分区就是交换分区,(windows平台叫虚拟内存) 在物理内存不够用时, 操作系统会从物理内存中把部分暂时不被使用的数据转移到交换分区, 从 ...
- 小白自制Linux开发板 五. Debian文件系统制作,以及WIFI配置、交换分区配置
该片文章将完整记录一个Debian的最小文件系统的生成,以及自定义配置WIFI组件.网络组件和交换分区配置 本文章参考:https://whycan.com/t_4236.htmlhttp://www ...
- Linux设置交换分区swap
参考: http://www.vpser.net/opt/vps-add-swap.html https://www.zntec.cn/archives/vps-swap.html http://yz ...
- linux 交换分区 swap
linux swap分区用来保证内存过载时也可以使用,是在磁盘级别对内存的一次扩展,swap分区必须是一个单独的分区 创建过程: 1.用fdisk 命令新建分区,在创建过程中通过L命令和t命令来调整分 ...
- Linux - 创建交换分区 swap
购买的 1GB 内存的 Linux 小机器,在编译安装 PHP 的时候内存捉急,只好开启 swap 交换分区来增大内存. [root@VM_139_38_centos php-7.2.12]# cat ...
随机推荐
- 修改FreeBSD启动菜单停留时间
原文:http://blog.chinaunix.net/uid-21782158-id-11006.html 分类: 两种情况: 一.启动时出现菜单的时候要停的10秒 方法: 编辑/boot/loa ...
- mac os x 连不上android 手机
在系统关于中查询mac的usb的厂商ID 如id为0x2717 执行echo 0x2717 >> ~/.android/adb_usb.ini 即可
- Excel Interior.ColorIndex色彩列表
Microsoft.Office.Interop.Excel.Range range; ; i < dt.Columns.Count; i++) { worksheet.Cells[, i + ...
- php 关于stripslashes 和 addslashes的使用
一.首先要先说到 php magic_quotes_gpc .(get_magic_quotes_gpc()可以检测是否开启) PHP magic_quotes_gpc作用范围是:WEB客户服务端: ...
- Git-仓库基本结构
三 Git 仓库 1.1Git 基本概念 在Git中,我们将需要进行版本控制的文件目录叫做一个仓库(repository),每个仓库可以简单理解成一个目录,这个目录里面的所有文件都通过 ...
- (一)s3c2440 地址分配讲解 (很难很纠结)
mini2440的地址怎么分配.mini2440处理器的地址怎么分配. S3C2440处理器可以使用的物理地址空间可以达到4GB,其中前1GB的地址(也就是0x0000 0000--0x4000 00 ...
- FRM-40831 出现截断
此问题还有一种情况: 在form搜索界面使用时间范围搜索时遇到的 当在PRE-QUERY中调用如下查询时,如果CUX_SUM.PERIOD_NAME的字段长度要设置的长一些,个人建议是前面2个字段的2 ...
- 关于C#中的new的用法
修饰符:隐藏基类中的成员(是基类中的成员,所以字段.属性.事件等等都可以隐藏,不单单是方法哦) public class Car { public void WriteName(string name ...
- 图论$\cdot$2-SAT问题
2-SAT问题是这样的:有$n$个布尔变量$x_i$,另有$m$个需要满足的条件,每个条件的形式都是“$x_i$为真/假或者$x_j$为真/假”.比如:"$x_1$为真或者$x_3$为假“. ...
- 关于ifram之间的相互调用
window.iframeId.btnClose.click(); 父调子 window.parent.FatherFunciton(); 子调父