What Is Virtual Memory?

What Is Virtual Memory

Date First Published: 24th July 2023

Topic: Computer Systems

Subtopic: Computer Software

Article Type: Computer Terms & Definitions

Difficulty: Medium

Difficulty Level: 6/10

Learn about what virtual memory is in this article.

Virtual memory is a portion of a hard drive or solid-state drive (SSD) that is reserved to compensate for shortages of RAM. This happens when the amount of RAM needed to run programs and data is more than the amount of available RAM. Instead of returning an 'out of memory' error or forcing programs to close, the computer can swap the main memory into virtual memory. Virtual memory settings can usually be controlled through the operating system.

A system using virtual memory has a section of the hard drive or SSD to mimic the RAM. Virtual memory is useful for multitasking, improving system performance, using intensive programs, and saving users from having to increase the RAM capacity when the space runs out. But, it is not recommended to rely on virtual memory too much since it is much slower than the RAM and can result in computer performance issues.

Performance Issues

When programs are temporarily loaded from the hard drive, they will load much slower than the RAM and result in reduced performance. This is because a hard drive is a secondary storage device and the processor has to wait for data to be swapped between the hard disk and the RAM.

When the operating system has to excessively switch between the main memory and the virtual memory, it is known as 'thrashing'. This happens when the virtual memory is overused, which will cause a very high hard drive access rate and harm the computer performance until the issue is fixed. Thrashing can be fixed by forcing some running programs to close and adjusting the size of the swap file. If it is persistent, the recommended way to fix the issue is to increase the RAM capacity, but this can be expensive.

All hard drives need at least some free space for virtual memory. When there is a shortage of available RAM, a file is created on the hard drive for overflow tasks. But, if there is not enough free space for this, it won't be able to effectively support the main memory. This may cause the computer to slow down, crash, or freeze.

Types Of Virtual Memory

The two main types of virtual memory are:

  • Paging - This allocates virtual memory into sections or paging files. When all the available RAM is used, unused pages are transferred using a swap file (the space on the hard disk reserved for virtual memory). The swap file is sent back to the RAM when it is needed, a process known as page swapping. The paging process uses page tables to translate the virtual addresses the operating system and applications use into the physical addresses that are used by the memory management unit.
  • Segmentation - With segmentation, virtual memory is allocated into segments of different lengths. Unused segments in the memory can be moved to the virtual memory space on the hard drive. A segment table keeps track of whether a segment is present in the memory, whether it has been modified, and its physical address.
Note: Info Icon

Although these two processes are different in terms of how virtual memory is allocated, they can be combined.


Feedback

  • Is there anything that you disagree with on this page?
  • Are there any spelling, grammatical, or punctuation errors on this page?
  • Are there any broken links or design errors on this page?

If so, it is important that you tell me as soon as possible on this page.


Comments