I don't know how VM really works for everything else, but for IRIX another UNIX flavor, here's a summary.
When coder/developers creates an application/binary... they usually reserve the maximum memory needed for the application to run. So when you run the application it goes out and mark pages of memory for reserve, sadly, even though it really needs to use a fraction of it. It is a common practice for these coders to always reserve the max, and something even more than what the application really needs. In IRIX, instead of using REAL physical memory, instead the kernal goes out an reserve swap memory, but allows the application to use the physical memory when it needs it. The the code goes out to reserve memory, the kernel force it to reserve the swap space, because it's not really using it anyway, and for the pages of memory it is actually using, it reserves the real memory. This allows the system to optimize real memory usage. VM is not a replacement for physical memory, but more like a another partition of memory where reserve memory are swap to. Without it, the kernel will start reserving the real memory, and you'll find yourself quickly running out of memory. So even if you have loads of memory, like over 1G of ram, it's still would add significant performace increase to use VM.
Here's an example: You have an application, APP. When you run it, it will reserve 64M of memory, but of the 64, it uses only 4M. The system will swap out 60M into swapspace, and use only 4M of real memory that it actually needs. Without it, it will reserve all 64M of your real memory. If you only have 128M of ram, you'll find yourself quickly out of memory. The system simply runs more efficient with VM.
It's common that most application will reseve 2X to 2.5X or even 4X the actually memory it needs. Ir depends on the coder. Thats pretty much why ppl say you need swap space 2-4X your physical memory.
The second usage is, when you dont have enough physical memory, then the kernal actually goes out and swap to swap space. I guess this is the method most users are familiar with. Useful for low memory systems, but will deteriote performace.
I know this is not the most technically correct way to explain it. I'm sure some UNIX guru can explain it much more accurate than I can, but I hope it gives you an idea.
So bottom line, even if you got adequate meory. Using VM is still recommended.
NEXT:
Swap file VS. Swap Partition.
In the unix world, creating a swap file is the means to temporary add more swap space. It is by no means a permanent swap. WHY? Simply because swapping to a file requires reading and writing to a few extra layers. That means it's a hell of a lot slower than swapping to a raw swap partition. Any system that swaps to a file vs swapping to a partiton is comparable a lot slower. If you have a Linux (or FREEBSD) system handle, you can try it and compare. For example Linux with a partition performs a lot faster (memory wise) than with just a swap file.
This is what dissappoints me about osX. It's pretty fast now, but I want to see how much faster it can be if, I can create a raw partition. Doing a man on fstab says that it's possible. But osX doesn't seem to use the fstab to activate swap like Linux or BSD. Because I can create a raw partition, but cannot tell osX to swap to it. /etc/fstab seems to be ignored.
Anyone else looked into this? I'm sure there is a way! I dont think apple will go through the trouble in stripping out that piece of code in the kernel.
-devinci