What's the difference between "virtual memory" and "swap space"?

algo-geeks picture algo-geeks · Feb 11, 2011 · Viewed 90.8k times · Source

Can any one please make me clear what is the difference between virtual memory and swap space?

And why do we say that for a 32-bit machine the maximum virtual memory accessible is 4 GB only?

Answer

Viral Shah picture Viral Shah · Feb 11, 2011

There's an excellent explantation of virtual memory over on superuser.

Simply put, virtual memory is a combination of RAM and disk space that running processes can use.

Swap space is the portion of virtual memory that is on the hard disk, used when RAM is full.

As for why 32bit CPU is limited to 4gb virtual memory, it's addressed well here:

By definition, a 32-bit processor uses 32 bits to refer to the location of each byte of memory. 2^32 = 4.2 billion, which means a memory address that's 32 bits long can only refer to 4.2 billion unique locations (i.e. 4 GB).