What is the difference between virtual memory and built-in memory (RAM)?

I allocated ~24GB of my hard-drive as "virtual memory" -- what I understand to be extra space that the computer can use as RAM. My system has 8GB RAM built in, so my assumption is that I'm pumping a whopping ~32GB of available RAM.

virtual memory allocation

My question is, is that ~24GB of virtual memory less efficient than my built in RAM? And probably more importantly, what is the real difference between virtual memory and physical RAM?


Solution 1:

The definition of Virtual Memory per the SU tag (which I wrote):

Virtual memory is a technique to provide more address space than the available physical memory (the installed RAM).
Each process can be given its own virtual memory, and the hardware (the Memory Management Unit, MMU) translates every virtual memory reference to a physical memory address.

To accommodate situations when more virtual memory is in use than actual physical memory, space on a storage device (the backing store, or swap space or page file) such as HDD, SSD or even thumb drive can be used to "swap out" memory data and later "swap (back) in" as needed.
The swapped memory data is usually in data lengths called pages, but there are alternate schemes that use variable length segments or even paged segments.

The dialog box you are showing is to configure the amount of disk space for the page file.
You are not allocating virtual memory. If you're using a 64-bit CPU and OS then there are 2^64 bytes of virtual memory per process.

Virtual memory has evolved from just a technique to provide more address space. Virtual memory is a key component in providing security to each process, so that a process cannot interfere with another process, not be compromised by another process.

ADDENDUM

A difficulty in describing Virtual Memory is that Microsoft has taken upon itself to re-invent the description of how VM actually works in Windows, and has published misleading explanations like this and this.
But the proper definition of Virtual Memory accepted by non-Microsoft OS developers and modern CPU designers, and how it actually works in computers is described in this computer architecture presentation.
VM is not a trivial topic, so apparently MS has twisted the explanation to describe the net benefits and the equivalent role of the paging file. Most unfortunately, MS has also chosen to occasionally refer to the paging file as "virtual memory", as if "Virtual Memory" actually resided external to the CPU and memory subsystem, which is contrary to what anyone learns in a computer architecture course and what Virtual Memory actually is.

Note that the MS Windows "explanation" of their Virtual Memory makes no mention of memory protection between processes. That omission is a clue that this explanation is bogus. The use of Virtual Memory is a crucial mechanism to ensure security in a computer, and to prevent one application program from breaking other programs or the whole PC. MS Windows does not use an alternate mechanism to isolate processes; it uses Virtual Memory with the provided MMU hardware just like other operating systems do.

ADDENDUM 2

Here' a Microsoft technical article that tries to use conventional memory management terms. The mapping of "virtual address spaces" to physical RAM is the salient operation of what the computer community knows as memory mapping of virtual memory.

A range of virtual addresses is sometimes called a range of virtual memory.

The insertion of "sometimes" is a bit strange, as if to acknowledge the conventional definition of "virtual memory" that the non-MS world uses and yet not contradict the MS (mis)use of this term.
Virtual addresses correspond to virtual memory, just like physical address correspond to physical memory.

Solution 2:

Virtual memory is where loaded but not current processes can be parked.

Programs in memory are ready to be used straight up. It's like having an open book on the desktop. Stuff that's in the swap file, is like having the book open at the right page, but sitting on the dresser behind you. It has to be brought to the desk first, before use.

Stuff that is not open is like being in the bookcase. You have to fetch the book and then open it to the right page.

Having more real memory is like having a bigger desk: more can get done straight up. Too much virtual memory can be a killer too, because what's open on the dressers etc, is managed on the desktop or real memory.

Speed is the main marker here.

Also, windos can only cope with a fixed memory size, esp 32 bit stuff So unless you're using win64, 4gb is well enough.