Saturday, November 15, 2008

No more virtual memory!

Virtual memory is exactly what it sounds like, fake memory. A simple example is, say you have 4 MB of memory and you want to run 5 programs each needing 1 MB of memory. When you run the 5th program the operating system takes 1 MB of memory that hasn't been used in a while and writes it to the hard drive. This frees up the memory allowing the 5th program to run. Now if another program requests the memory that is on disk, the operating system has to swap something with it. This is slow. For most users, the operating system manages it and you never have to think about it. Virtual memory is great and it's allowed people to multitask easier without having to worry about memory. But....

Memory is so incredibly cheap these days, I recently upgraded to 8GB of memory and turned off virtual memory my pagefile. My thinking is before I had 4GB of memory and a 4GB pagefile and my system ran great. Now that I have 8GB I shouldn't need virtual memory a pagefile. Why not have both? Windows is notorious of being a memory hog, the more there is, the more it uses. Disabling virtual memory the pagefile is the only way to force windows and other programs to use only physical memory. Have you ever heard your hard drive spin up when switching programs? Not me anymore!

UPDATE: I used a very layman use of the term virtual memory because my point was the hard drive swapping. In reality virtual memory does a lot more than just swap data from the RAM to the hard drive. It allows applications to use contigous memory when it actually may be fragmented or across various media. This is very important and cannot be turned off. Turning off the pagefile will prevent any harddrive swaps but if I ever do use my entire 8GB of ram, I might have some performance issues. Does disabling the pagefile help? I would assume that windows trys to leave some free memory for applications so it doesn't always need to swap and disabling the pagefile may increase the amount of physical memory left unallocated. With a lot of RAM it probably doesn't make much of a difference either way. In practice my system is running great but I haven't done any strenuous testing.


For more information, read this article on pagefile optimization.