Tap to Read ➤

What is Virtual Memory

Ashwini Kulkarni Sule
Virtual memory acts as a supplement to the RAM and forms a part of RAM and hard disk. It gives the user a feeling that he has RAM of unlimited capacity while the application program is under the impression that it has an unfragmented working memory.
Virtual memory has become very common for most computer operating systems. Computers these days have RAM space available in different sizes. Considering the huge demand placed by computer users on the application programs, this space is not sufficient. Also users expect all these programs to run simultaneously, which is not possible within the available space. Hence, the need for virtual memory.

What is it?

It is a technique which tricks an application program into believing that it has a contiguous address space and unlimited working memory. While the fact is that, the memory may be physically fragmented or extended on to disk storage. Systems that use virtual memory are capable of executing large applications at a fast rate and use real physical memory more efficiently than those without it. Virtual memory is different from the concept of memory virtualization.

Working

It is an intelligent method of utilizing the computer's actual memory capacity and manipulating it by using the combination of the operating system and memory hardware capabilities. It acts as a temporary storage medium, in which the data is stored in a file format.

Your browser doesn't support HTML5 video.

Since the operating system acts as the determinant, it provides quick access to the data and allows smoother operating capacity.
Virtual memory works in coordination with RAM by storing and presenting data quickly, to serve the requirements of an application program. Secondary storage device like hard disk, has a large storage capacity but it provides a very slow access to the data.

How is it Organized?

It is organized by either paging or segmentation. Most of the systems use page tables to translate the virtual addresses seen by application programs into physical addresses used by the processor to execute instructions. Page table maintains entries for mapping a virtual address to physical address.
Systems may have a single page table for the entire system or an individual page table for every application program. Thus, paging can be defined as the process of moving inactive virtual memory pages to the disk and restoring them to real memory upon request.
There are various algorithms to select which pages should be moved to the hard disk and which should be retained.
Very few systems use the concept of segmentation for implementing virtual memory. In segmentation, the memory is divided into variable size of segments. Segment number and an offset within it, together form a virtual address. If a processor wants a particular data item, it first looks up for its segment number in the table to find a segment descriptor.
Segment descriptor gives information whether the offset within the segment is less than the length of the segment and if it isn't, an interrupt is generated to notify that the segment is found.
If the processor is unable to find it in the main memory, it generates a hardware interrupt, prompting the operating system to swap in the segment. The operating system then searches for the segments that were not in use for a long time and swaps them out of main memory, in order to make space for the new segments to be read in.

How to Increase it?

Here is a step by step guide to increase the virtual memory of your computer. (For Windows only):
  • Click on the start menu and then go to control panel
  • Select performance and maintenance, and under that select system
  • Select settings on the advanced tab under the heading called performance
  • On the advanced tab under virtual memory, select change
  • Under drive [volume label], select the drive that contains the paging file that you wish to change
  • Under paging file size for selected drive, click on the check box ― custom size
  • You can choose the amount of memory you wish to reserve for virtual memory by entering the initial and maximum size
  • Click on set
  • Restart the computer when prompted
If you find your computer running slow then increasing virtual memory won't help, as it might be just the result of 'thrashing'. Shuffling blocks of virtual memory between real memory and disks consumes most of computer's time, thus causing thrashing. Though well-designed application programs may help to solve this problem to a certain extent, the ultimate cure is to install more real memory.