Click to See Complete Forum and Search --> : management of swap space


scanez
09-05-2001, 02:12 AM
How is swap space managed? Meaning, is swap space freed up like once a day or just everytime you restart or what? Is there a way to free up swap space manually?

Thanks
SC

Craig McPherson
09-05-2001, 02:37 AM
Swap space is fixed, ie not dynamically allocated. You create permanent swap space on disk (in the form of swap files or swap partitions), and during bootup they're "swapped on" which clears their contents and activates them as swap space. Memory itself is moved in and out of swap as neccessary. Technically, it's not swapping, it's paging. Swapping is a more limited form of paging, which Windows 3.x and older UNIX OS's used. With paging, individual memory pages can be written to and from disk, whereas with the older swapping, only entire applications could be written into the swap space, which was very limiting.

Malakin
09-05-2001, 06:37 AM
If you're bored you can always read the man pages on swapon, swapoff or mkswap :)

Craig McPherson
09-05-2001, 06:58 AM
I forgot to mention this in my post. swapd is a background program that can create new swap files if you ever run low on swap space, and then delete those files when they're no longer needed.

It's not terribly useful, though. The dynamic creation and deletion of a lot of small swap files can slow the system down terribly, and the Linux kernel supports a limited number of active swap spaces -- maybe 16. Once it reaches that limit, it'll fail. This can also be inconvenient for you. One time, I forgot to activate one of my swap partitions, and when I tried to swapon it, I couldn't do it because swapd had alrady created enough swap files to keep the kernel from allowing any more to be activated.