Knowledge of Virtual Memory

0

Virtual Memory

Using virtual memory is a way for the computer to accomplish more than the limits of what its physical memory can perform. The computer system uses a portion of the hard disk as if it was physical RAM. When all physical memory is filled, the OS can transfer some of the least-recently-used data from memory to a file on the hard disk called the pagefile, thereby freeing up an equivalent amount of space in main RAM for other purposes. When the original data is needed again, the next least-recently-used data is moved out of RAM onto the hard drive to make room to reimport the needed data.

Example:

Virtual Memory-01

Figure : Virtual memory.

Virtual Memory and RAM Speed

Virtual memory is not nearly as fast as actual memory. Modern SDRAM DIMMs read/ write speeds are measured in nanoseconds, whereas hard drive seek, read, and write times are measured in milliseconds. If your computer is frequently exceeding its physical RAM and having to resort to using a pagefile on disk, adding more physical RAM may be the most economic way of effecting a noticeable change in performance.

The Virtual Memory Process

When data is stored in virtual memory:

1.    An application loads and requests memory from the system.

2.    The Virtual Memory Manager (VMM) assigns it a page of memory addresses from within the virtual memory space.

3.    The application stores information in one or more of the virtual memory locations.

4.    The VMM maps the virtual address the application uses to a physical location in RAM.

5.    As physical RAM becomes full, the VMM moves inactive data from memory to the pagefile in a process called paging or swapping.

Storing and retrieving virtual memory data

Figure: Storing and retrieving virtual memory data.

When data is retrieved from virtual memory:

1.  An application requests data from its virtual memory location.

2.  The VMM determines which physical RAM location was mapped to this virtual memory address.

3.  If the VMM finds that the data is not present in the RAM location, it generates an interrupt called a page fault.

4. The VMM locates the data in the pagefile, retrieves the data from the hard disk, loads it back into RAM, and updates the virtual-to-physical address mapping for the application. If necessary, the VMM swaps other data out of RAM to release space.

5. The application retrieves the data from RAM.

Optimizing the Pagefile

When you install Windows, the system automatically creates a pagefile named Pagefile.sys at the root of the drive. The size of the pagefile varies within a range determined by the pagefile’s initial size value and maximum size value. The system sets the size values of the pagefile using an algorithm that takes into account the amount of physical memory and the space available on the disk. When the system starts, the pagefile is set to the initial size; if more virtual memory space is needed, the system adds it to the pagefile until it reaches the maximum size. An administrator can alter the initial and maximum size values to optimize the pagefile and virtual memory performance. In modern systems, there is rarely a severe shortage of either physical RAM or disk space, so optimizing the pagefile might not be an issue, but you can consider the following tips:

  • Although Microsoft recommends an initial pagefile size of 1.5 times the amount of RAM, the more RAM you have, the smaller a pagefile you need.
  • If the initial size of the pagefile is too low, the system will waste time as it adds more space to the pagefile. Adding space to the pagefile after startup also increases disk fragmentation. Consequently, it is often a good idea to set the initial size to the same value as the maximum size. If the initial size is too high, however, the pagefile will be mostly empty, which wastes disk space.
  • If you get a lot of “low virtual memory” errors, increase the maximum size of the pagefile.
  • If you have multiple drives, you can move the pagefile off the drive that contains the Windows system files, so that the computer can access system files and pagefile information simultaneously. Put the pagefile on the fastest drive that does not contain Windows.
  • If there is not a noticeable speed difference between drives, create additional pagefiles on multiple drives. This speeds access time because the system can read and write from multiple drives simultaneously. However, there is no performance advantage to putting the pagefile on different partitions on the same disk.

                                    ————— Thanks everyone

Share.

About Author

TN365

Leave A Reply

CAPTCHA ImageChange Image