Thursday 13 May 2021

Linux System is using to much swap memory

A value from 0 to 100 which controls the degree to which the system favors anonymous memory or the page cache. A high value improves file-system performance, while aggressively swapping less active processes out of physical memory. A low value avoids swapping processes out of memory, which usually decreases latency, at the cost of I/O performance.

The default is normally 60 in Linux but devices running custom Linux builds may change the value.

  1. Check / Note the default setting
    1. SSH in to the unit and switch to root
    2. run "cat /proc/sys/vm/swappiness"
  2. Lower the value, I normally set it to 10, but 0 would shut the swap process down, 100 would make it swap all the time.
    1. run "echo 10 > /proc/sys/vm/swappiness"
    2. run "swapoff -a"
    3. run "swapon -a"
Retest performance of the unit,  sometimes the swapoff will fail as they is not enough memory to offload the swap data too.  You will need to free up memory or reboot.  Just bear in mind that the command at this time is none permanent and rebooting will switch it back to default.

This is good in case the change kills the device, rebooting will bring it back to normal.  Once you are happy its fixed the issue / runs better you can do two things expand the RAM or make the charge permanent.

No comments:

Post a Comment