SWAP AREAS

9/15/2001

Swap Areas: Swap areas are used by multi-tasking operating systems to backup areas of memory to slower, but larger, storage devices -- almost always hard drives. Swapping is built into Linux (although it can be turned off). Swapping was added to the DOS world in an early version of Windows.

In most (all?) multitasking operating systems, memory is allocated in pages of a few thousand bytes. When all of memory is in use and more is requested, unused or rarely used pages are swapped out to mass storage. When (and if) they are needed, they will be brought back. Swapping is a slow process. In order to reduce head positioning overhead, groups of pages are often swapped in and out as a single entity. Computer operations can take a very long time if, as sometimes happens, swapping it is going on continuously. This can occur even when it would seem that there are adequate resources to avoid constant swapping. In that case, the result is generally referred to as "thrashing".

In order to speed up swapping, disk space used for swapping is usually manipulated directly by the memory manager without going through file look up logic. This can cause major problems if there are discrepancies between the swap memory manager's concept of disk layout and the disk manager's concept. In Linux, the swap space can be either a file or a partition and if it is a file, the space must be allocated contiguously. In Windows, swap files can be either fixed size or dynamically allocated. They are configured under the somewhat confusing heading of "Virtual Memory". Note that Windows sometimes (erroneously) allocates swapping to a compressed drive, but will not use swap space on a compressed drive. This effectively turns swapping off.

Common Problems associated with swapping include:

http://web.archive.org/web/20100917054603/http://adriansrojakpot.com/Speed_Demonz/Swapfile_Optimization/Swapfile_Optimization_01.htm

Return To Index Copyright 1994-2002 by Donald Kenney.