Virtual memory enables a system to run larger applications or run more applications at the same time without running out of random access memory (RAM). Specifically, the system can operate as if its total RAM resources were equal to the amount of physical RAM plus the amount of virtual RAM.
Virtual memory is an important technology for enterprises with key applications that have high central processing unit (CPU) requirements. High-capacity storage devices, like hard disk drives (HDDs) and solid-state drives (SSDs) enable business-grade application performance. They also save businesses money because using a storage device for virtual memory costs less than having a large CPU. In this guide, learn all about virtual memory and how it can help IT teams.
Guide to virtual memory
- How virtual memory works
- Advantages of using virtual memory
- Disadvantages of using virtual memory
- Virtual vs. physical memory
- Two types of virtual memory
- Example of how virtual memory is used
- How to manage virtual memory in an OS
- Bottom line
How virtual memory works
Virtual memory is an area of a computer system’s secondary memory storage space, such as an HDD or SSD, that acts as if it were a part of the system’s RAM or primary memory.
Ideally, the data needed to run applications is stored in RAM, where the CPU can quickly access it. But when the system is running large applications or when many applications are running at once, the system’s RAM may fill completely.
There’s a workaround to this problem: data stored in RAM that isn’t actively being used can be temporarily moved to virtual memory, which is physically located on a hard drive or other storage device. This frees up space in RAM, which can then accommodate data the system needs to access immediately.
By swapping data between RAM and virtual memory when it is not needed and back from virtual memory to RAM when it is needed, a system can continue to work smoothly with far less physical RAM than it would otherwise require.
Learn about the difference between memory and storage.
Advantages of using virtual memory
Virtual memory has multiple advantages for computer systems:
- More applications can run at the same time on the same system
- Larger applications can run on systems that don’t have enough physical RAM alone to run them
- Increasing memory with virtual memory is less costly than buying more RAM
- It increases memory in a system that already has the maximum RAM that its hardware and OS can support.
Disadvantages of using virtual memory
Virtual memory has a few disadvantages as well:
- It doesn’t offer the same performance as RAM
- It can negatively affect the overall performance of a system, causing slowdowns
- It takes up storage space, which could otherwise be used for long-term data storage
Virtual vs. physical memory
Virtual memory is a form of logical memory. Logical memory is read by computers as primary memory, but it exists on a local drive and isn’t directly accessed by the CPU. The computer reads the address for logical memory as though it is in the motherboard as well. However, because it’s not actually in the motherboard, retrieving this data can take longer than retrieving data from volatile memory.
In comparison, physical memory, the space specifically dedicated to RAM on the computer’s motherboard, is volatile. That storage only exists when the computer is powered on, and it disappears when the computer shuts down.
Two types of virtual memory
Memory management systems use two types of virtual memory methods to improve application performance.
Paging
In a system that uses paging, RAM is divided into a number of blocks called pages, usually 4K in size. Processes are then allocated just enough pages to meet their memory requirements. This means there will always be a small amount of memory wasted, except in the unusual case where a process requires exactly a whole number of pages.
During the normal course of operations, pages are swapped between RAM and a page file, which represents the virtual memory.
Segmentation
Segmentation is an alternative approach to memory management: Instead of pages of a fixed size, the memory management system allocates segments of differing length to processes to exactly meet their requirements. Unlike in a paged system, no memory is wasted in a segment.
Segmentation also allows applications to be split up into logically independent address spaces, which can make them easier and more secure to share.
One downside to segmentation is that because each segment is a different length, it can lead to memory fragmentation. As segments are continually allocated and de-allocated, small chunks of memory are scattered within the memory space. They’re too small to be useful.
As these small chunks build up, fewer and fewer segments of useful size can be allocated. It’s difficult for the OS to keep track of all these segments, and each process will need to use multiple segments. This is inefficient and can reduce overall application performance.
Read more about paging and segmentation.
Example of how virtual memory is used
An IT manager uses an Apple laptop, which runs macOS. They have all their standard work applications, like Gmail and Slack, active. But they also use Atera, a popular remote monitoring and management software. This platform allows IT managers to monitor all company devices and employee usage statistics. This program uses more memory than the laptop’s RAM can handle at one time. To compensate for the lack of memory, the computer’s memory management unit moves the virtual memory data to the CPU.
If the virtual memory performance of the IT manager’s computer declines, swapping the secondary memory format, a hard drive, to a solid-state drive may speed performance. SSDs are flash memory, and overall, they read data faster than hard drives.
How to manage virtual memory in an OS
On Windows, after navigating to the start menu and to settings, enter performance in the search bar. Choose adjust the appearance and performance of Windows. Select the advanced tab in the window that comes up. In the virtual memory section, select change. Enter desired sizes in the initial size and maximum size boxes; both values are in megabytes.
In Mac operating systems, adjusting virtual memory is a little less simple. One tactic to increase performance is to add more storage space to a computer’s RAM. However, this is expensive. Installing a larger hard drive creates more virtual memory capacity. Users can also reset the parameter random access memory (PRAM) and non-volatile random access memory (NVRAM).
Bottom line: Importance of virtual memory
Virtual memory increases the capability of companies’ computers and servers by providing additional space aside from the limited capacity of the CPU. Although virtual memory is slower than random access memory, it’s critical for overall operating system performance.
Virtual memory combined with physical memory enables computers to support both more applications and allocate enhanced storage resources. The virtual memory provided by secondary storage is used by organizations to equip computers to handle greater data loads.
Read more about memory management in computer systems next.