Technology

What is Virtual Memory and Why Do Operating Systems Use It?

The main difference between real and virtual memory is that the real memory actually exists in a computer in the RAM chip, whereas the virtual memory does not really exist. Virtual memory is just an optimization strategy that the operating system uses in order to empower the applications running on it, and giving an impression that such applications have more memory than the memory that actually exists. This concept of virtual memory can be found in almost all operating systems these days, such as Windows, Mac and Linux.

How Virtual Memory Works

Imagine a scenario where a program needs to run on the operating system and it would require around 100 MB to function properly, but the system has only 50 MB. In order to cover up the remaining requirement of 50 MB, the operating system will generate 100 MB virtually, and will generate the additional 50 MB by creating an additional file on the hard disk, called a paging file, or a swap file. There is a program on operating systems called virtual memory manager, or VMM, and it will be the responsibility of this program to execute the application requiring 100 MB.

In order to do so, VMM will find those spots in the computer where the RAM has not been used, and assign that memory to the virtual memory. So in reality a swapping process is taking place in the background where real memory swapped to the virtual memory through the paging file.

Why Virtual Memory Is Necessary?

The main job of VMM is to make the application think that there is enough memory available to run it. This is done because of two reasons:

There are some programs that require a lot of memory, and this is where virtual memory can come in handy.

Virtual memory also allows multi-tasking. Without virtual memory, a computer might not be able to run an email program and a Microsoft word file simultaneously.

Impact Of Virtual Memory

It is quite evident that virtual memory has more control as compared to real memory, and this control can result in swapping of memory from the real memory to the virtual memory through paging files on hard disk. This multi-tasking can potentially slow down the computer.

Leave a Reply