1. Introduction

In this tutorial, we’re going to describe physical and virtual memory in a nutshell. After that, we’ll briefly give details about virtual memory, and then we’ll summarize the differences between them.

2. Physical Memory

As primary storage, early computers employed delay lines, Williams-Kilburn tubes, or rotating magnetic drums. By the 1950s, magnetic core memory had mostly been displaced by such unreliable and faulty technologies. Until the 1970s, core memory remained in its place. After that, semiconductor memory has become economically competitive due to advancements in integrated circuit (IC) technology.

This led to modern random-access memory (RAM) of a computer is known as a physical memory or primary memory. It usually sits on the motherboard. Physical memory is a volatile memory, and it has a limited size because of the RAM chip. As a result, it needs a consistent flow to store data. On the other hand, power issues and interruptions have the potential to erase data from the physical memory.

Physical memory can also be accessed in a linear manner. To put it another way, the memory address increases in a linear fashion. Also, it holds the instructions of programs to execute, and it is the only storage type that the CPU can access directly. The below figure shows a RAM known as a physical memory or primary memory:

ram freeimages

The hard disk generally stores the programs. It takes longer for the CPU to access the hard disk every time in order to execute programs. Therefore, if physical memory initially stores the programs, the CPU can process them more quickly.

Accessing data via physical memory requires less time than accessing data from a hard drive. The programs return to the hard drive when they have completed their execution. Similarly, a new application can use free memory in order to run. We call them processes when they start to execute.

3. Virtual Memory

As we mentioned above, the primary memory such as RAM is limited and costly in the system. However, secondary memory such as disk is cheaper and large, and we can increase its size easily.

Virtual memory is a memory management strategy that creates an image of a very extensive memory for users. As we have mentioned above, we have limited physical memory. Virtual memory lets physical memory idealize the abstraction of the storage resources so that these resources are really accessible on a given computer.

This concept provides a one-of-a-kind method for apparent primary memory extension. This allows us to access secondary memory as if it were a part of the main memory. One approach for extending this is to temporarily move unused RAM storage to secondary storage.

Virtual memory essentially enables access to more memory than what is actually stored on the system. It maintains this by moving data from the RAM to the disk, with the assist of the operating system (OS) and the software and hardware installed on the computer. Let’s see how the virtual memory works in the figure below:

virtual memory

3.1. Where Is the Virtual Memory?

Virtual memory exists in the form of pages with the help of the OS. These pages are atomic units that can store enormous programs. There might be a lot of storage in physical addresses for software. Since only specific programs are utilized for an application, all of those are not needed to be loaded.

Assume that we’re playing a game like GTA on a computer. When we need to install the game, we install the game on a secondary storage space like a hard disk. Actually, the entire files of the game are not loaded into RAM. However, RAM stores certain parts of the game when we start to play it.

3.2. How Virtual Memory Works?

Both the hardware and the software work together to map virtual addresses to physical addresses. Additionally, the memory management unit (MMU) helps while translating these addresses.

We see logical addresses instead of physical addresses in the operating system. At load, execute, or compile-time, the system translates these logical addresses dynamically. It also depends on the system’s need or the definition of the system.

Processes and resources kept in the memory are not continuous in real scenarios. In fact, the system breaks down and spread across them throughout the physical memory. We can easily achieve this with the use of dynamic run-time address translation and a page or segment table.

4. Differences Between Physical and Virtual Memory

Rendered by QuickLaTeX.com

5. Conclusion

In this tutorial, we briefly defined physical and virtual memory.

Additionally, we detailly tried to give an intuition about why we need such two separate entities. Finally, we summarized their differences in a table.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.