There are two factors to consider - how much you actually need for correct operation of your system, and how much you might need in case of a kernel panic.(An interesting discussion of Linux swapping is at https://kerneltrap.org/node/3202)
Unix and Xenix are virtual memory operating systems. If you have, say, 16 MB of RAM and a 20 MB swap device, you have 36 MB of virtual memory available, of which the operating system will keep 16 MB in memory (whatever space it uses, plus the most recently used user memory). Therefore, the total of swap space plus physical RAM must equal or exceed the greatest amount of physical memory your system will need.
If you have no idea what this is about, this not very technical Understanding Virtual Memory and Swap Space may help get you started.
The kernel, however, will check how much swap space is available whenever a program executes a system call which may require more swap space, such as fork() or malloc. There must be enough free swap space to hold the memory which the system call will allocate, or else the system call will fail. This is a safety precaution which applies even if no swapping is required! So you will need as much swap space as you will have swappable memory (generally, stack and data regions).
Under Unix, you can use the crash command to check how much swap space has been allocated. Once in crash, type od -d availsmem to see the value of availsmem. This is a kernel variable which is measured in 4k units (i.e. pages in the i386 memory architecture) and which says how much more memory can be allocated. Any request for a number of pages greater than the current value of availsmem will fail. See TA 482712 for some more information on availsmem.
Of course, in order to know how much swap space you need, you need to have an idea of how much total virtual memory your programs will require. Some need more than others. For example, if you're running any Java components, you may need a lot of swap space; check the release notes for details. X Windows generally eats a lot of memory, so you'll want plenty of swap space if you do much work in X. Your applications' documentation may give you information on how much swap/memory they require.Also see:
The other consideration relates to system panics, and does not apply to Xenix. Should a system panic occur, the kernel will dump the contents of physical memory into the dump device (which is usually the same as the swap device but does not have to be). There is a net.rumour that should you have more physical memory than swap space, it will overwrite whatever's next to the swap device with the dump. It is possible to force the kernel to overwrite something with a poor choice of parameters on the Boot: line (e.g. explicitly giving an incorrect size for the swap device), but without this form of prompting, the kernel will not dump any more memory than it believes will fit into the device specified for dumps.
One final comment - swapping is a wonderful thing, in that it allows you to use more memory than you actually have. However, disk is several orders of magnitude slower than memory, and so the more swapping you have, the slower your system will run. If you find your system is swapping and that is having a noticeable effect on performance, you should consider adding memory if your hardware and OS support more memory than you have.
Got something to add? Send me email.