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 ...
随机推荐
- center的用法
(1)先 frame ,决定大小,也就是宽.高 (2)再center,决定位置, 需要注意的是,不能直接写center,需要通过CGPointMake(x,y)赋值
- java虚拟机内部介绍
一.介绍 java 的内存管理和垃圾回收在某种程度是同一个问题来着.对于java程序员来说,在虚拟机自动内存管理机制的帮助下,不在需要为每一个new操作去写配对的delete/free代码,不容易出现 ...
- Bibtex使用方法
BibTeX 是一个使用数据库的的方式来管理参考文献程序, 用于协调LaTeX的参考文献处理. BibTeX 文件的后缀名为 .bib . 先来看一个例子: @article{Gettys90,aut ...
- Leetcode: Battleships in a Board
Given an 2D board, count how many different battleships are in it. The battleships are represented w ...
- PHP读取XML文件数据
XML文件 <?xml version="1.0" encoding="UTF-8"?> <node> <student> ...
- Ubuntu 安装BCM 43142无线网卡驱动
ubuntu14.04 安装 bcm43142无线网卡 用命令lspci 查看无线网卡类型 然后下载对应的无线网卡驱动. 之后,使用下列命令安装,即可搜索无线热点了: sudo apt-get ins ...
- 将n*n矩阵顺时针旋转90度
/** * 将n*n矩阵顺时针旋转90度 * @param mat * @param n 矩阵的阶数 * @date 2016-10-7 * @author shaobn */ public stat ...
- ASCII编码表
最初的编码:ASCII 补充: ASCII表是适用于美国的,共128位:ISO-8859-1是适用于欧洲的,共256位 :GB2312是适用于中文系统的:UTF-8是万国码,适用于绝大部分语言:ANS ...
- [SDN] What is SDN?
本篇学习笔记写于 Sun Nov 13 15:08:02 2016, 可能有认识不全面的地方. 参考资料为ONF的官方网站中: Software-Defined Networking (SDN) De ...
- WebForm带有图片的验证码
验证码形成的部分在一个aspx文件中: 页面设置 <%@ Page Language="C#" AutoEventWireup="true" CodeFi ...