Virtual Memory
Virtual Memory is a memory management technique that allows an operating system to use part of a storage device (HDD or SSD) as if it were additional RAM.
It makes the system appear to have more memory than it physically has.
How it works
Every program thinks it has its own large, continuous block of memory.
But in reality:
- Physical RAM is limited
- The operating system divides memory into small blocks called pages
- Some pages stay in RAM
- Others are temporarily stored on disk (in a swap file or page file)
When a program needs data that is not in RAM, the system loads it from disk into memory. This process is called paging.
Paging and Swap
There are two important concepts:
Paging – moving memory pages between RAM and disk.
Swap space – a reserved part of storage used for virtual memory.
If RAM becomes full, less-used data is moved to swap space.
Why it is important
- Allows running more applications at the same time
- Prevents system crashes due to low memory
- Provides memory isolation between processes
- Improves system stability
Without virtual memory, programs would be strictly limited by physical RAM.
Advantages
- Better multitasking
- Efficient memory usage
- Process protection
Each process has its own virtual address space, which increases security.
Disadvantages
Accessing data from disk is much slower than accessing RAM.
If the system constantly swaps data between RAM and disk, performance drops. This situation is called thrashing.
Virtual vs Physical Memory
- Physical memory = actual RAM hardware
- Virtual memory = abstraction created by the operating system
Virtual memory makes memory management more flexible.
A simple example
Imagine your desk (RAM) is small, but you have a cabinet (disk). When the desk is full, you temporarily move some documents into the cabinet. When you need them again, you bring them back to the desk.
Related terms
- What is Process?
- What is Kernel?
- What is RAM?
Source
Information simplified from the Wikipedia article “Virtual memory”.