Slashdot Mirror


Why Use Virtual Memory In Modern Systems?

Cyberhwk writes "I have a system with Windows Vista Ultimate (64-bit) installed on it, and it has 4GB of RAM. However when I've been watching system performance, my system seems to divide the work between the physical RAM and the virtual memory, so I have 2GB of data in the virtual memory and another 2GB in the physical memory. Is there a reason why my system should even be using the virtual memory anymore? I would think the computer would run better if it based everything off of RAM instead of virtual memory. Any thoughts on this matter or could you explain why the system is acting this way?"

9 of 983 comments (clear)

  1. You mean physical memory right :-) by alain94040 · · Score: 5, Informative

    You must be confused about virtual vs. physical memory. In modern processors, there is no penalty for using virtual memory, all translation from virtual to physical address space is done internal to the processor and you won't notice the difference.

    So all the physical memory installed in your PC is used by the processor as one big pool of resources. Processes can think whatever they want and address huge memory spaces, that's all in virtual land. Virtual memory only starts impacting performance when pages are being swapped in and out, because all your processes need more resident memory than you actually have.

    Swapping means accessing the disk and freezing the requesting process until its page of memory has arrived from the disk, which takes millions of processor cycles (a lifetime from the processor's point of view). It's not so bad if you swap once, as the processor can work on other processes while waiting for the data to arrive, but if all your programs keep pushing each other out of physical memory, you get thrashing and consider yourself happy if the mouse pointer is still responsive!

    So you may want to change the title of your post to: "why use physical memory in modern systems?". I would point you to an article I wrote on that topic in 1990, but somehow I can't find a link to it on the web :-)

    fairsoftware.net - software developers share revenue from the apps they build

    1. Re:You mean physical memory right :-) by TypoNAM · · Score: 5, Informative

      Sorry, got to correct the path to where exactly I got that quote from:
      System Properties -> Advanced -> Performance area, click Settings -> Advanced tab (on Windows XP, as for 2000 its the default tab).

      --
      This space is not for rent.
    2. Re:You mean physical memory right :-) by hardburn · · Score: 5, Informative

      It never did change. "Virtual Memory" always meant a trick the kernel and CPU do to make programs think they are accessing a different memory address than they actually are. This trick is necessary in all multitasking operating systems.

      Once you've made the jump to mapping real memory addresses to fake ones, it's easy to map the fake addresses to a swap file on the hard drive instead of actual RAM. The confusion of the terms started when naive programmers at the UI level called that swap file "virtual memory".

      --
      Not a typewriter
    3. Re:You mean physical memory right :-) by nmb3000 · · Score: 5, Informative

      Either he/she thinks "Virtual Memory" is the same thing as paging

      Physical memory, virtual memory, address space, and paging files are some of the most misunderstood things your average computer "expert" deals with. When it comes to Windows, few can probably explain why only 3GB of 4GB physical RAM shows up on a 32-bit system. Fewer even can probably define the difference between "virtual memory" and "paging file".

      I highly recommend any Windows users or administrators read Mark Russinovich's latest blog entry Pushing the Limits of Windows: Virtual Memory . It goes over all these things and describes the difference between virtual memory, committed memory, and why it really is important to have a paging file, even on that system with 8GB of physical RAM. Should be required reading for any Windows admin.

      --
      "What do you despise? By this are you truly known." --Princess Irulan, Manual of Muad'Dib
      /)
    4. Re:You mean physical memory right :-) by qw0ntum · · Score: 5, Informative

      I know it was a joke but actually, in an oversimplified sense, yes. A main point of virtual memory in its true sense is to abstract the limitations of your amount of physical memory away from user programs, and instead present them with an effectively limitless virtual address space with which to work with. When the program says, "read from memory address 0x(some huge number)", the OS/memory management unit will translate that address request from a virtual page address to a physical frame via the page table. If there is no frame in memory that contains the data pointed to by the requested address, that's when you have a page fault. Then the operating goes to disk and fetches the data you requested.

      Your performance would be abysmally slow, and obviously probably wouldn't work at all with modern operating systems (just a theoretical point here!), but assuming a good implementation of virtual memory you should be able to run everything just fine. Of course, if you don't have enough disk space for your address space, you'll run into problems. :)

      --
      'Every story, if continued long enough, ends in death.' --Ernest Hemingway
    5. Re:You mean physical memory right :-) by mikael_j · · Score: 5, Informative

      Clearly someone has never done tech support, and I don't mean "helped friends/relatives fix something" I mean in the trenches, taking calls all day long, every day.

      Trust me on this one, there are lots of really stupid people out there, and sadly tech support is a great place to find out that being intelligent and friendly don't help when you're faced with some guy with a "fancy" last name, an e-mail address that indicates that he is a partner at a well-known law firm and serious entitlement issues ("I WANT THIS FIXED NOW YOU GOD DAMN MOTHERFUCKING HIGH SCHOOL DROPOUT LOSER PUNK DO YOU HAVE ANY IDEA HOW MUCH MONEY I'M LOSING EVERY HOUR THAT MY (residential $15/month DSL) BROADBAND ISN'T WORKING I'M GONNA FILE A FUCKING LAWSUIT I WANT A FUCKING SUPERVISOR RIGHT GOD DAMN NOW YOU SHITHEAD LAZY KNOW-NOTHIN....", well you get the point). Also, when there's an outage these are the people who make you aware of the outage before the NOC calls to tell you about it because within 30 seconds of their DSL going down there's going to be about 50 of these people waiting to yell at you for the DSLAM getting destroyed by a direct lightning strike (and yeah, I've had to deal with something like 50% of the idiots who called about that particular outage demanding to speak to a supervisor because they felt I wasn't doing my job when I explained that it would take several days to repair the building the DSLAM was housed in before a replacement DSLAM could be installed. Also, this is the kind of person who works as a lawyer while somehow being unaware of the term "force majeure").

      To sum it up: There are lots of stupid assholes out there, it's not just plain stupidity due to genetic factors, there's also the issue of people who simply choose to stay uneducated about even the most basic computer skills (while relying on their computer to do their job) like understanding the difference between "a program" and "a website" or how to find the start menu in WinXP/Vista...

      /Mikael

      --
      Greylisting is to SMTP as NAT is to IPv4
  2. Re:Vista reserves 1 GB by El+Lobo · · Score: 5, Informative

    Absolutely not true. You can even install and run Vista on a computer with 1Gb ram and no page file. And run applications. So it doesn't reserve 1Gb for itself and thus, your myth is busted. Vista's memory manager will use as much memory it can (free memory is a waste, so it will use it rather than watch it empty). But as soon as a process needs memory it will give it back.

    --
    It's time to realise that Abble's products are the biggest abomination these days. Just say NO to the dumb iAbble way!!
  3. Virtual Memory v Paging by clarkn0va · · Score: 5, Informative

    thinks "Virtual Memory" is the same thing as paging...

    Mac Classic (OS 8 for sure) used the term "Virtual Memory" the same way Windows today uses "Page File" or unix uses "swap", so you can at least understand why some people might be confused by this.

    db

    --
    I am literally 3000 tokens away from the chaotic crossbow --Stephen
  4. Re:Vista reserves 1 GB by d3vi1 · · Score: 5, Informative

    I think he is referring to the userspace/kernelspace split in Windows NT. On 32bit Windows XP, by default, the userspace (ring3) will have at most 2 GB of the physical RAM, and the kernel space would get the rest (some of it paged and some of it not). On systems with more than 3G of RAM (a lot by 2002 standards), it was kinda pointless to reserve that much for the kernel space, so they added a boot.ini flag that changed the split to _AT_MOST_ 3GBytes for the userspace and the rest for kernel space.
    In Vista the split for 3G/1G of RAM is default. Actually on a system with 4G of RAM running in 32bit mode, you can't use all of them even if you try (in Windows XP), because right under the 4G limit you would have the PCI memory address mappings, that can be as large as 512M for a common video card with half a gig of RAM. Add to that the RAID controllers and the other hardware, and you have about 800megs of RAM unused because they can't be addressed, as their address-space is used by the installed devices.
    I think that http://support.microsoft.com/kb/823440/ and http://support.microsoft.com/kb/171793/ should describe what I'm talking about pretty clearly.

    --
    UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever ones.