Do I still need to use virtual memory?

14

2

I would have thought this was already asked but I can't seem to find it.

At what point do I no longer need virtual memory enabled? With 4GB of RAM I see that the computer rarely uses anywhere near all of it. At that point virtual memory isn't strictly necessary. Is there danger in turning it off? Are there features I'll lose if I do?

Steve Rowe

Posted 2009-10-14T06:00:46.147

Reputation: 3 729

1Attention: There is only a limited amount of memory given to drivers, called the non-paged and paged pool memory sections. A page file is necessary for when the paged section gets full, as a gamer I have seen a game complain about paged pool memory just because I had my page file disabled on a 8 GB system. Conclusion: Page files are necessary, they prevent paged pool depletion and actually do speed up your system. – Tamara Wijsman – 2011-10-24T16:28:38.483

Answers

9

Since memory is not exactly a sparse resource on desktop PCs / laptops anymore, I doubt that most programs can handle out-of-memory conditions gracefully and will crash instead.
So: Dangerous? Yes, if your 4GB are used up somehow and you have no pagefile, applications may start to crash.
And as shown in Zoran's example it may be hard to identify the problem later on.

The article, that Ram refers to, also states, that turning swapping off usually doesn't improve speed and may do the opposite instead:

So while there may be some workloads that perform better with no paging file, in general having one will mean more usable memory being available to the system

foraidt

Posted 2009-10-14T06:00:46.147

Reputation: 4 398

I will have to dig up the article on MS's site, but MS does say you should always have a pagefile. Even on high memory systems, not having one can make your machine run slower. – Keltari – 2012-08-24T01:08:33.010

10

See Mark Russinovich's article on Virtual Memory. That should give you a good pointer about Virtual Memory.

Here's a useful excerpt from the link

So how do you know how much commit charge your workloads require? You might have noticed in the screenshots that Windows tracks that number and Process Explorer shows it: Peak Commit Charge. 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.

Prabhu R

Posted 2009-10-14T06:00:46.147

Reputation: 1 434

+1 for Mark Russinovich reference. Always a great read. – mrduclaw – 2009-12-14T19:49:57.237

3

This classic post on ServerFault has some good points. For only 4GB I'd leave the pagefile alone, and the space involved on the disk is minor in any case.

MartW

Posted 2009-10-14T06:00:46.147

Reputation: 1 852

3

I'd recommend to leave the virtual memory settings to their default. I have 8GB of RAM and turned virtual memory off thinking I would gain in speed (because of no swapping), but it turns out that made my system less stable (and I did this on 2 machines, similar result). I was experiencing one BSOD per week approximately, on both machines. I started examining the minidumps produced and found out that all the BSODs were triggered by a call to a routine called KiPageFault. So I tried setting the virtual memory settings back to their defaults, and the regular BSODs disappeared.

Took me quite a while to correlate the 2, and I have no actual evidence that the fact that I turned off virtual memory caused the BSODs, but my machines were more stable after I turned it back on...

Zoran

Posted 2009-10-14T06:00:46.147

Reputation: 999

Thanks. It is good to hear real results and not just suppositions. – Steve Rowe – 2009-10-15T01:34:37.190

0

Depends what your workload is. I've set up a bunch of diskless frontends for a web application. They network booted and ran everything they needed within 8GB of ram.

I've also used windows (98 probably) with 32MB and no pagefile - of course you have to live in that memory space and limit your apps to suit the resources.

You do want to make sure that there is some extra RAM for the disk cache, otherwise performance can become horrible.

I seem to recall that there are some programs that won't run without VM, but I have no idea what they were

gnibbler

Posted 2009-10-14T06:00:46.147

Reputation: 256

-2

Well, Steve, interesting that you should ask that.

I will tell you a little secret: the point at which you needed virtual memory was never. Virtual memory was an insanely incompetent idea created by a bunch of academics who knew zero about practical computing systems, and ANY computer will function vastly better if it can be made to run without VM.

Now, you might ask, if VM is useless and harmful, why do most big modern operating systems use it? The short answer to this question is that the people deciding whether to use VM or not at Microsoft, Apple and IBM were even more stupid and inexperienced than the academics who invented VM and wanted to adopt it based on the same, completely incorrect assumptions that the academics had when they invented it. We could start talking about those assumptions and misconceptions, but unfortunately, if they were easy to understand and describe we would not have the VM problem in the first place.

Getting back to you. Unfortunately, just like the aforementioned tardnoggins at Apple and Microsoft, you have your own misconceptions, namely the idea that you can turn off VM. Of course, you cannot turn it off, that would defeat the whole purpose of screwing you if you could just turn it off. When people do something really stupid, they always make sure it is irreversible. After all, if everybody could just turn off VM, they would, and that would make the bozos who created it look pretty stupid wouldn't it? They prevented this possibility by making it unremovable, kind of like Microsoft made Internet Explorer unremovable.

What you can do is limit the size of the page file, which of course should be set to whatever the minimum is, hopefully 0. Virtual Memory is still there, but at least you can reduce it from very very very slow to just very very slow by asking it to not involve the disk drive in the insanity.

Tyler Durden

Posted 2009-10-14T06:00:46.147

Reputation: 4 710

Virtual memory allows a great many good things. If you didn't have virtual memory then you would have to have enough RAM to hold every byte of code and data that every process on your system defines, whether or not it was ever actually referenced. Since most programs spend 90% of their time using 10% of their code and data this would be a huge waste. You would also lose many other useful things, which the comment format here doesn't give me room to outline. The reason we haven't abandoned virtual memory is that it's still a really, really good idea. Even in "practical computing systems". – Jamie Hanrahan – 2017-07-21T03:42:46.337

@RickBrant You sound like the idiot electrical engineers from Intel and IBM I use to have to listen to back in the 1980s trying to explain why VM was a good idea. I remember back when IBM came out with OS/2, which was the first operating system brain damaged with VM, having to listen to them explain why it was such a great idea. Well, thank god OS/2 died, but unfortunately VM kept going, like a zombie, so here it is 2017 and I am still listening to this nonsense.I'll bet dollars to donuts you don't have a CS degree, do you? That's the joke part. 99% of the guys promoting VM are not programmers – Tyler Durden – 2017-07-21T07:44:29.363

I was a dual major in fact, CS/EE, at one of the best tech schools on the west coast. Today I am mostly a programmer, but I do interact with hardware types. Now, do you have a cogent rebuttal to the point that it would be very wasteful to have to keep every last byte of code and data a program defines in RAM at all times, whether it needs it or not? Because virtual memory avoids that. Or are you going to continue with personal attacks that amount to "you must be an idiot"? – Jamie Hanrahan – 2017-07-21T23:30:06.260

Oh, and re "OS/2, which was the first operating system brain damaged with VM," Um, no, not by about two decades. Maybe the first widely-used OS for PCs. (But not the first for "personal computers".) – Jamie Hanrahan – 2017-07-21T23:32:23.717