Allocating Sufficient Swap Space
swap space in UNIX and Linux or a pagefile in Windows is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space.
As a sysadmin you always try to minimise swapping because it causes significant operating system overhead. To check if your server is swapping, use the
If your system is swapping and you must conserve memory then:
- Avoid running unnecessary system daemon processes, services or application processes.
- Decrease the number of operating system file buffers, especially if you are using raw devices.
- Decrease the number of database buffers to free some memory.
Determine swap space
To determine the amount of swap space, run the following commands based on your operating system:
|Solaris||swap -l -or- swap -s|
|True64 UNIX||swapon -s|
|Windows¹||wmic pagefile list /format:list|
|Mac OS X||ls -lh /private/var/vm/swapfile* swapfiles are generally staggered in size, ranging from 64MB to 512MB.|
Adding swap space
To add swap space to your system, run one of the following commands, depending on your platform:
|AIX||chps -or mkps|
|Tru64 UNIX||swapon -a|
|Windows¹²||wmic pagefileset where name="<drive>:\\pagefile.sys" set InitialSize=<size>,MaximumSize=<size>|
|Mac OS X||swap space is allocated dynamically. If the operating system requires more swap space, then it creates additional swap files in the
Notes: ¹ wmic must be run via an administrator elevated priviledge command-prompt. ² A reboot of the Windows server is needed for the change to take effect.