linux swap占用过多,解决Linux中Swap被长期占用问题

You can also control at which point the system starts to use swap memory. This will tell you what is the current value in your computer:

cat /proc/sys/vm/swappiness

Linux default used to be 60. Roughly speaking, this means that the computer will start using the swap partitions when as little 40% of RAM is being used. This was a safe default for old machines. However, if you have plenty of RAM, you can reduce the swappiness.

On the fly:

sudo sysctl vm.swappiness=10

sudo swapoff -a

sudo swapon -a

Or permanently by adding vm.swappiness = 10 to /etc/sysctl.conf (for Debian).

# free -m

total used free shared buffers cached

Mem: 64410 43406 21004 0 219 24696

-/+ buffers/cache: 18489 45920

Swap: 4095 4091 4

# cat /proc/sys/vm/swappiness

60

# echo "vm.swappiness=10" >> /etc/sysctl.conf

# sysctl -p

# swapoff -a -v

swapoff on /dev/sda2

# swapon -a -v

swapon on /dev/sda2

swapon: /dev/sda2: found swap signature: version 1, page-size 4, same byte order

swapon: /dev/sda2: pagesize=4096, swapsize=4294967296, devsize=4294967296 # free -m

total       used       free     shared    buffers     cached

Mem:         64410      47661      16748          0        222      24721

-/+ buffers/cache:      22717      41692

Swap:         4095          0       4095

swappiness=0的时候表示最大限度使用物理内存,然后才是 swap空间,

swappiness=100的时候表示积极的使用swap分区,

并且把内存上的数据及时的搬运到swap空间里面。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值