Virtual memory is the process of using a section of secondary storage (your hard drive) to give the illusion of extra memory (RAM).
All open programs require a share of RAM, as do the files you are working on.
Some files and programs are simply too big to fit into the RAM available. This is particularly true when creating videos and large graphics.
Alternatively, you may just have too many files or programs open at any one time.
The operating system will utilise virtual memory (your hard drive) when the physical RAM in a computer system is not sufficient to cope with the files and applications currently in use.
Virtual memory will allow you to continue multitasking and accessing large files despite your RAM being limited or full.
Pages and Paging
A page is a fixed length contiguous (consecutive) block (unit of data) of virtual memory.
Paging is the name given to the process of storing and retrieving data between a HDD/SSD and RAM.
Pages of data are transferred between RAM and virtual memory when needed.
Paging is essential for virtual memory to work.
Drawbacks of virtual memory
Virtual memory is not without issues.
Secondary storage cannot directly access the CPU so data will constantly need to be swapped between RAM (primary memory) and the virtual memory space on the hard drive.
This is extra work for the computer, so not ideal and may affect performance.
The thrash point is achieved when most processes come to a stop because the computer is too busy dealing with virtual memory paging (moving data in and out of memory). It simply cannot cope with the current demands of using virtual memory.
High levels of thrashing is obviously not desirable and can be resolved by:
- Getting more RAM
- Using an SSD, not HDD
- Having less programs running