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/swappinessLinux default used to be 60. Roughly
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空间里面。
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)