"Virtual" in the computer industry is a word
meaning that something is other than what it appears to
be. Many people have difficulties to understand what
virtual memory actually means. Virtual memory is memory
that does not exist. Several contradictory definitions
about virtual memory exist. For some, virtual memory is
not disk space. Disk (swap) space is used for backing
allocated (committed) memory (global data, heap and
stack) when the OS ran out of system memory (RAM).
Example: You create a program and define a stack of 64KB.
Because your program really doesn't require 64KB (only
2KB), the OS will allocate only one page (4K) during
run-time. The other 64KB - 4KB = 60KB is virtual memory;
memory that does not exist, not in system memory, not on
disk. Only when your program runs out of stack, another
page will be allocated unless a total of 64KB is used
already.From another point of view, Virtual Memory
isn't memory at all, but hard disk space made to look
like it; the opposite of a RAM disk. Windows (and System
7) uses virtual memory for swap files, used when
physical memory runs out (you need protected mode on a PC
to do that). Like disk cacheing, VM was used on
mainframes for some time before migrating to the PC; VMS,
the OS used on DEC VAXes, actually stands for Virtual
Memory System. There is a speed penalty, of course,
as you have to access the hard disk to use it, but
Virtual Memory is a good stopgap when you're running
short.