Home » Questions » Computers [ Ask a new question ]

Do I still need to use virtual memory?

Do I still need to use virtual memory?

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

Asked by: Guest | Views: 325
Total answers/comments: 3
Guest [Entry]

"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"
Guest [Entry]

"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..."
Guest [Entry]

"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.

I guess I will briefly discuss why VM is a bad idea for the 1% who actually care, even though it is not what the OP asked.

Out of the box, VM is bad because it indirects memory so it slows down any memory-involved operations by 5x to 10x. If a disk is involved, then the slow down becomes much more pronounced, anywhere from 10x to 100x slower. The net result is that a computer using a VM is generally AT LEAST 10x slower than the same computer which does not use VM. So, that is the bad. Also, it makes the computer more complicated, because now there are two different sets of addresses, hardware addresses and virtual addresses.

The supposed benefits of using a VM are two: (1) it creates a flat memory addressing scheme, and (2) it allows the amount of memory to be increased dynamically by moving rarely used memory to disk. On paper these sound like great advantages, but in the real world they do not come close to compensating for the performance degradation.

(Re 1) Virtually all computer languages using memory managers (C, Java, etc). Therefore, application programmers do not care whether there is a flat memory space or not, because the memory manager takes care of that. As far as the memory managers themselves are concerned, writing a manager which can use a discontinuous set of memory addresses is only marginally more difficult than one which does not. So the advantage of (1) is more or less inconsequential to 99% of programmers.

(Re 2) In real life, VMs that use disks frequently use the disk even though they supposed to ""rarely"" use the disk. Anyone who has watched the disk thrash in the early days (1980s) knows this. Modern Windows computers are so polluted with VMs and OS-related garbage that they thrash continuously, even if no applications are running at all. The advantage that the VM prevents the user from getting an ""out of memory"" error, is a false advantage. I would much rather have my computer run faster and get the occasional out of memory error. It is true that modern computers do not give out of memory errors--they just slow down and become completely unusable so you have to reboot the whole machine. With direct memory access, you just close the offending program and keep going, a much better way of doing things."