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.
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.
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