Swapping
Aus Wiki-WebPerfect
Version vom 21. August 2020, 09:09 Uhr von Admin (Diskussion | Beiträge)
Memory swapping is a computer technology that enables an operating system to provide more memory to a running application or process than is available in physical random access memory (RAM). When the physical system memory is exhausted, the operating system can opt to make use of memory swapping techniques to get additional memory. Mostly, swapping means the os outsource some memory to the swap space on a disk (In Linux this is a disk partition and in Windows there is a swap file called "pagefile.sys")
Display processes using swap space (Linux)
find /proc -maxdepth 2 -path "/proc/[0-9]*/status" -readable -exec awk -v FS=":" '{process[$1]=$2;sub(/^[ \t]+/,"",process[$1]);} END {if(process["VmSwap"] && process["VmSwap"] != "0 kB") printf "%10s %-30s %20s\n",process["Pid"],process["Name"],process["VmSwap"]}' '{}' \; | awk '{print $(NF-1),$0}' | sort -h | cut -d " " -f2-
Swappiness configuration
Get current used swap space:
free -h
Get current swappiness configuration
sysctl vm.swappiness
Change swappiness for the current session (swappiness config are removed after reboot):
sudo sysctl vm.swappiness=0
Change swappiness persitent (in sysctl.conf under /etc/)
# Add this line to change swappiness from a default (60) to 0 (decrease swap usage) vm.swappiness = 0