Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is Virtual Memory, and how should I configure it on my computer?

System Maintenance

What is Virtual Memory, and how should I configure it on my computer?

by  CitrixEngineer  Posted    (Edited  )
Virtual Memory is traditionally an area of hard disk space that is reserved for use when physical RAM has been filled up.

The Operating System runs a background program called a Virtual Memory Manager, which is a task or service that continually monitors memory usage and maintains an index of where application data resides in memory.

Virtual Memory is often referred to as swap space or a page file.

Swap space refers to the process of swapping known quantities of data from memory to disk and back again. This term is used on UNIX-based computers, which typically have an entire partition reserved for memory swapping.

The process of paging simply means that data is divided into contiguous slices, called pages. The pages are given handles, or page Ids, by the Virtual Memory Manager. Pages are called back into operation as and when required, although they are only stored for a finite period of time.

This may result in a Page fault, if the page required is either not found or invalid (ie another page may have overwritten the previous one). Page faults are common, and not worth worrying about unless excessive.

Windows NT-based computers store pages in a system file named pagefile.sys, but DOS-based Windows computers will give the extension .swp. E.g. Windows 98 names its swapfile win386.swp.

One thing Windows-based computers have in common, apart from versions 3.11 and previous, is that the swapfile is set to be dynamic by default. This gives the Virtual Memory Manager plenty to do, as it continually adjusts the size of the pagefile to accept the quantities of data that need to be cached.

It can also keep the disk fairly busy too. If youÆve ever noticed that something appears to be accessing your hard disk while you are taking a break, or not actively using your computer, chances are itÆs the VMM.

One other (two-part) problem with leaving Windows to manage the Virtual Memory is that the pagefile can grow fairly large, and requires contiguous space on the disk to fill.

The first part of the equation is not generally an issue, with hard disks now averaging 10-20 Gigabytes û and larger. The second part can be more complex, since most people add data to their hard disks on a regular basis.

If youÆve ever seen an ôOut of Memoryö error on a computer with a large amount of RAM and a vast hard disk, youÆve probably seen a computer that has run out of contiguous space for the pagefile.

There are at least 3 ways of dealing with this issue;
1) Reboot the computer, run the Defragmentation tool, and reboot.
2) Delete the pagefile and reboot.
3) Set the initial and maximum size to be the same amount and reboot.

The first 2 options have the disadvantage that the problem is likely to recur.

The 3rd option has the advantage that it will stop the Virtual Memory Manager from continually resizing the pagefile, possibly giving a performance boost, and also that the ôOut of Memoryö problem is likely to go away.

If youÆre running several heavyweight applications simultaneously, and creating multiple files that run into 10s or 100s of megabytes, however, you may well actually be out of memory.

How big the file should be depends on whose set of calculations you use. Where it should be stored is also a matter of preference.

My recommendations and reasoning are as follows;

Size should be at least equal to the amount of RAM. After all, it is the contents of RAM that are written to the pagefile. I usually make it equal to 1.5x RAM. This is because the Operating System itself has a working set which needs to be swapped, if it is not currently in use.

The root partition is a good place for it. This is because if it is in the root, then the system can write a full memory dump to it in the event of a crash.

If debugging is not at all of interest to you, but performance is, then another partition on another disk is the best location for your pagefile. This gives the Operating System the opportunity to minimise the time between application data and virtual memory reads; Since your system bus will typically run hundreds of times faster than a disk head can move between sectors, telling a controller to search a different disk will give results far quicker than telling it to search a different location on the disk it has just read.

If you have plenty of RAM, and there is a further cache setting in your virtual memory manager tool, then set that to be as large as possible. Modern computers have literally dozens of caches, of which the pagefile is the biggest and most obvious û and the more and the bigger, the better!

If you have any comments on this faq, or would like to have a link to your own, more in-depth faq on any aspect of it, please contact me citrixengineer@yahoo.co.uk

Please note that I have tried to avoid deep technical discussions for the sake of brevity and clarity, and that the recommendations and reasoning section comprises my own opinions, backed up with information that I believe to be accurate. I would like to know if any of the information is inaccurate û I certainly did not intend it to be!

I have not knowingly used anyone elseÆs work in the preparation of this document. If you see work you believe to be your own, again, please contact me.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top