views:

1059

answers:

10

Virtual memory was introduced to help run more programs with limited memory. But in todays environment of inexpensive RAM, is it still relevant?

Since there will be no disk access if it is disabled and all the programs will be memory resident, will it not improve the performance and program response times?

Is there any essential requirement for virtual memory in windows apart from running more programs as stated above? Something windows internal not known to us.

+10  A: 

Don't disable virtual memory. 2GB is not nearly enough to even consider this. Regardless, you should always keep virtual memory on even if you do have enough since it will only ever be used when you actually need it. Much better to be safe than sorry since NOT having it active means you simply hit a wall, while having it active means your computer starts swapping to the hard drive but continues to run.

Soviut
Thats got to be the first piggyback post I've seen here.
StingyJack
Aaron you should post your own answer; reverting this change now that it's reopened
Jeff Atwood
A: 

Unfortunately, it is still needed because the windows operating system has a tendency to 'overcache'.

Plus, as stated above, 2GB isn't really enough to consider turning it off. Heck, I probably wouldn't turn it off until I had 8GB or more.

G-Man

GeoffreyF67
Its not unfortunate, its how all modern operating systems work and is basically an essential service at this point for reasons that are explained in other answers.
Soviut
+13  A: 

Some pedantry: virtual memory is not just the pagefile. The term encompasses a whole range of techniques that give the program the illusion that it has one single contiguous address space, some of which is the program's code, some of which is data, and some of which are DLLs or memory-mapped files.

So to your lead-in question: yes, virtual memory is required. It's what makes modern OS's work.

kdgregory
I know my answer sounds a little like a repeat of yours, but I wanted emphasize the process memory protection aspect of VM.
RussellH
Yes, although the relevance of the pagefile may be questioned, the whole concept of Virtual Memory is definitely something of the present and the future.http://en.wikipedia.org/wiki/Virtual_memory
RaphaelSP
So can the pagefile be set to zero in large memory systems?
Navneet
+5  A: 

Yes, because it's the basis of all on-demand paging that occurs in a modern operating system, not just Windows.

Windows will always use all of your memory, if not for applications then for caching whatever you read from your hard drive. Because if that memory is not used, then you're throwing your investment in memory away. Basically, Windows uses your RAM as a big fat cache to your hard drives. And this happens all the time, as the relevant pages are only brought into main memory when you address the content of that page.

Dave Van den Eynde
+2  A: 

Grrr. Disk space is probably always going to be cheaper than RAM. One of my lab computers has 512MB of RAM. That used to be enough when I got it, but now it has slowed to a crawl swapping and I need to put more RAM in it. I am not running more software programs now than I was then, but they have all gotten more bloated, and they often spawn more "daemon" programs that just sit there doing nothing but wait for some event and use up memory. I look at my process list and the "in-memory" column for the file explorer is 40MB. For Firefox it's 162MB. Java's "update scheduler" jusched.exe uses another 3.6MB. And that's just the physical-memory, these numbers don't include the swap space.

So it's really important to save the quicker, more expensive memory for what can't be swapped out. I can spare tens of GB on my hard drive for swap space.

Memory is seen as cheap enough that the OS and many programs don't try to optimize any more. On the one hand it's great because it makes programs more maintainable and debuggable and quicker to develop. But I hate having to keep putting in more RAM into my computer.

Jason S
+3  A: 

Your question is really about using a page file, and not virtual memory, as kdgregory said. Probably the most important use for virtual memory is so that the OS can protect once process's memory from another processes memory, while still giving each process the illusion of a contiguous, flat virtual address space. The actual physical addresses can and will become fragmented, but the virtual addresses will appear contiguous.

Yes, virtual memory is vital. The page file, maybe not.

RussellH
So can pagefile be set to zero in large memory systems?
Navneet
I wouldn't. I was speaking theoretically, that maybe some future OS from Microsoft will properly support disabling the pagefile. They don't recommend it (http://support.microsoft.com/kb/308417). SSD drives could also make the impact less.
RussellH
+4  A: 

The question is really what is the use of a pagefile considering how much memory modern computers have and what's going on under the hood in the OS.

It's common for the Windows task manager to show not much physical memory being used, but, your having many page faults? Win32 will never allocate all it's physical memory. It always saves some for new resource needs. With a big pagefile vs small pagefile, Win32 will be slower to allocate physical memory to a process.

For a few days now I've been using a very small pagefile (200 MB fixed) in Vista with 3GB of addressable physical memory. I have had no crashes or problems. Haven't tried things like large video editing or many different processes open at once. I wouldn't recommend no pagefile since the OS can never shuffle pages around in physical memory leading to the development of holes. A large pagefile is fail-safe for people who wouldn't know how to manually increase the pagefile if a low memory warning pops up or the OS crashes.

Some points: The kernel will use some of the physical memory and this will be shared through VM mapping with all other processes. Other processes will be in the remaining physical memory. VM makes each process see a 4GB mem space, the OS at the lower 2GB. Each process will need much less than the 4GB of physical memory, this amount is it's committed memory requirement. When programming, a malloc or new will reserve memory but not commit it. Things like the first write to the memory will commit it. Some memory is immedietely committed by the OS for each process.

jeffD
Experienced possible thrashing when trying to run a DVD so I upped dynamic pagefile expansion to 700 MB, no problems since.
jeffD
Actually, the OS is generally in the upper 2GB (or sometimes just 1GB).
SamB
+1  A: 

A good explanation at http://blogs.technet.com/markrussinovich/archive/2008/11/17/3155406.aspx

To optimally size your paging file you should start all the applications you run at the same time, load typical data sets, and then note the commit charge peak (or look at this value after a period of time where you know maximum load was attained). Set the paging file minimum to be that value minus the amount of RAM in your system (if the value is negative, pick a minimum size to permit the kind of crash dump you are configured for). If you want to have some breathing room for potentially large commit demands, set the maximum to double that number.

Navneet
+1  A: 

Virtual memory is much more than simply an extension of RAM. In reality, virtual memory is a system they virtualizes access to physical memory. Applications are presented with a consistent environment that is completely independent of RAM size. This offers a number of important advantages quite appart from the increased memory availabilty. Virtual memory is an integral part of the OS and cannot possibly be disabled.

The pagefile is NOT virtual memory. Many sources have claimed this, including some Microsoft articles. But it is wrong. You can disable the pagefile (not recommended) but this will not disable virtual memory.

Virtual mmeory has been used in large systems for some 40 years now and it is not going away anytime soon. The advantages are just too great. If virtual memory were eliminated all current 32 bit applications (and 64 bit as well) would become obsolete.

Larry Miller Microsoft MCSA

A: 

Since there will be no disk access if it is disabled and all the programs will be memory resident, will it not improve the performance and program response times?

I'm not totally sure about other platforms, but I had a Linux machine where the swap-space had been accidently disabled. When a process used all available memory, the machine basically froze for 5 minutes, the load average went to absurd numbers and the kernel OOM killer kicked in and terminated several processes. Reenabling swap fixed this entirely.

I never experienced any unnecessary swapping to disc - it only happened when I used all the available memory. Modern OS's (even 5-10 year old Linux distros) deal with swap-space quite intelligently, and only use it when required.

You can probably get by without swap space, since it's quite rare to reach 4GB of memory usage with a single process. With a 64-bit OS and say 8GB of RAM it's even more rare.. but, there's really no point disabling swap-space, you don't gain much (if anything), and when you run out of physical memory without it, bad things happen..

Basically - any half-decent OS should only use disc-swap (or virtual-memory) when required. Disabling swap only stops the OS being able to fall back on it, which causes the OOM killer to strike (and thus data-loss when processes are terminated).

dbr