swapd is a dynamic swapping manager. It provides the system with as much swap space (virtual memory) as is required at a particular time by dynamicly creating swap files. This is more convinient than using fixed swap files and/or partitions because they (a) are unused most of the time and are just taking up disk space; and (b) provide a limited amount of virtual memory.
All values given on the command line will override config file values.
Displays the command line help.
Displays the copyright notice.
Location of an alternate configuration file.
Maximum number of swap files. No more than n swap files will be used. The default is 8 (as many as the default kernel will allow).
Memory limit in kilobytes. When the total amount of free memory gets below this number, swapd creates a new swap file.
Pause between memory checks in miliseconds (when the total amount of free memory is above memlimit).
Location of the PID file, usually /var/run/swapd.pid.
Swap directory where all the swap files are kept.
Swap file size (>=64k).
Timeout. If the last created swap file is unused for sec seconds, it will be removed. The last created swapfile is considered unused when there are more than memlimit + swapsize kb of free memory (physical + swap).
This is an example configuration file:
# swapd.conf - config file for swapd
# Copyright 2000 Neven Lovric <email@example.com>
# Memory limit in kilobytes.
# When the total amount of free memory gets below this number, swapd creates
# a new swap file.
# 16384 or more recommended
# Pause between memory checks in miliseconds.
# When the total amount of free memory is above <memlimit>, swapd will pause
# for <pause> miliseconds before checking memory again.
# 1000 should be ok for most systems
# Swap file size in kilobytes.
# >= 64, 4096 recommended
# Maximum number of swap files.
# No more than <maxswaps> swap files will be used.
# 0 = unlimited (as many as the kernel will allow)
# 8 = how many a default kernel allows
# Timeout in seconds.
# If the last created swap file is unused for <sec> seconds, it will be
# removed. The last created swapfile is considered unused when there are
# more than <memlimit> + <swapsize> kb of free memory (physical + swap).
# 60 is nice
# Swap directory where all the swap files are kept.
# PID file (where the currently running swapd stores it's PID so a new swapd
# can find it)
# Full path to mkswap.
The most important parameter which may drasticly effect performance is the memory limit. If the memory limit is low, (1) there may not be enough memory ready for a program to allocate at once or (2) swapd may not be able to create new swap files before we run out of memory. If your programs are
running out of memory, it will primarily be due to a low memory limit. If you really want to have a low memory limit, you should decrease the swap size and pause.
The second important parameter is the swap size. If you choose to use bigger swap files, you may experience slowdowns when swap files are created. On the other hand, small swap files may lower performance when there are many of them. The important thing is not to make them too big to create before we run out of memory.
Another important parameter is the pause, which should be shorter on faster systems. If it is too long, swapd may fail to detect rapid memory changes and therefore fail to create new swap files when they are needed. However, if you notice swapd is constantly using too much CPU, increase the pause.