Virtual Memory

What is Virtual Memory?

Virtual memory typically refers to a specific type of memory management technique used to provide additional memory to the hard drive of the computer. Actually, it is the method of using secondary memory as a part of main memory.

From a technical point of view, it is the method in which parts of the memory are stored on the hard drive. These sections are called the pages, which are loaded onto the real memory address as and when it is requested.

Understanding Virtual Memory

What is Virtual Memory

In simple terms, virtual memory is a specific feature of the operating system that compensates for the deficiencies in the physical memory of the computer system by using both hardware and software.

This is a specific feature of the operating system which is available on:

The working process of the virtual memory is typically temporary, and it involves swapping addresses between the RAM and the hard disk.

When you receive any message saying that the virtual memory is running low, you will need to do any one of the following:

In the Windows systems, this virtual memory is managed automatically, but it can also be done manually, provided that the default size of the virtual memory is not substantially large.

Types of Virtual Memory

Usually, there are two major types of virtual memory methods used by the memory management systems for improving the performance of the applications namely, paging and segmentation.

Read Also:  What is Address Space? Example, Size, Types & More

Paging

In this method, the RAM is divided into different segments or blocks, usually referred to as pages, each of 4K in size.

The processes are allocated these pages, which is enough to meet their memory requirements.

The pages are usually swapped between the page file and the RAM, in normal conditions. However, there is a chance that the memory will be wasted if the exact requirement of the process is not known and the entire page is not used.

Segmentation

In this method, segments of varying lengths are used instead of fixed sizes and allocated to processes so that they meet their exact requirements.

There is no wasted memory in this process, where the applications are divided into logically autonomous address spaces. This makes sharing them much easier and more secure.

However, the varying sizes of the segments may result in memory fragmentation, and the scattered chunks resulting from continuous allocation and deallocation may be too small to be useful. If they build up, allocation would be difficult.

The operating system will have a hard time keeping track of all these small segments, each of which needs using several segments.

This will make the system inefficient and lower the overall performance of the application.

Why Use Virtual Memory?

The main reason to use virtual memory is to deal with the situations when the computer system or a current program or set of programs runs short of physical memory and ceases to function.

Acting as a secondary memory, the operating system considers it to be a part of the main memory and therefore the program can continue running.

Actually, these addresses map the addresses of the programs into the addresses of the RAM so that these can be used for mapping onto the disk when there is no more space available.

The most significant use of these virtual addresses is that they allow the operating system to:

In short, the virtual memory is used to help the operating system in avoiding a lot of issues during operation.

Is It Good to Increase Virtual Memory?

To put it simply, it is not needed to increase or even decrease the virtual memory setting in general because it will affect the working of a program.

Read Also:  What is Disk Access Time? Formula, Example & More

Since the speed of RAM is higher than that of the virtual memory, using more of the latter will reduce the operational speed of the system instead of improving it.

It is true that managing virtual memory is quite easy, but it is not necessary because it may put the system at the risk of:

Typically, a Windows system will itself make the necessary adjustments to the virtual memory as and when needed on the fly, depending on the amount of installed RAM in the system and usage spikes.

This self-adjusting feature prevents the system from taking up a large space unnecessarily.

Still, some users may increase or decrease the virtual memory setting due to the following reasons:

However, if you decrease or even eliminate the virtual memory with the intention of freeing up more space on your hard drive, it may result in some specific errors or make the system unstable.

Therefore, any manual adjustments made to the virtual memory settings should be made at your own risk.

Typically, you should not try to do it if you do not absolutely need to do it and do not have firm guidelines about it.

Therefore, it is good to leave it in place as it is and let the system use virtual memory as much as it can.

Advantages

Disadvantages

Virtual Memory Vs Physical Memory

Examples of Virtual Memory

One of the most common instances of using a virtual memory is when you run several applications or programs at the same time on your computer system.

It can be loading your emails in the browser window while running the word processing software at the same time or shifting content management system and scheduling software.

Is Virtual Memory Always Used?

Yes, it is used always. You can say that virtual memory is used even when the total amount of memory needed by all of the current processes is not more than the amount of Random Access Memory (RAM) installed in the computer system.

It is only the main parts of the kernel of an operating system that can bypass the virtual address translation and directly use the addresses of the real memory instead.

Conclusion

So, now you know how virtual memory helps in dealing with the deficit in storage space on the hard drive more efficiently by transferring pages of data from the RAM to the hard disk storage.

The method uses both software and hardware for the process and is available on almost all major types of operating systems.