Virtual Memory Vs Real Memory

Discussion in 'macOS' started by XP Defector, Mar 14, 2007.

  1. XP Defector macrumors 6502

    Apr 5, 2006
    What are the differences apart from obviously one being real and the other virtual. I notice I have 2.0GB of Real memory, and 8.10GB of VM - so where does this figure come from? Does more real memory equate to more VM? And does your internal HD have some say on how VM behaviors and/or it's overall amount?
  2. MisterMe macrumors G4


    Jul 17, 2002
    You don't have 8.10 GB of virtual memory. Your OS has allocated 8.10 GB of hard drive space for virtual memory while you were checking it. MacOS X is based on BSD, a true preemptive multiuser multitasking virtual memory OS. Virtual memory is allocated by the OS as needed. This is not a user decision. The major role that you play is to ensure that your hard drive should be filled to no more than 90% capacity with the remaining 10% as free space. This gives the VM system the headroom it needs to problem do its job. Beyond that, don't worry about it.

    A word to the wise: Your System can be expected to always show your real memory filled to capacity. This is because free memory is wasted memory. A properly functioning VM system will use as much real memory as is available.
  3. ElectricSheep macrumors 6502


    Feb 18, 2004
    Wilmington, DE
    This isn't quite correct. The figure reported VM Size does not affect what is allocated on the hard disk at all.

    VM Size is a measure of the Total Virtual Address Space. Every application gets to play with about 2 gigabytes of virtual memory addresses, starting from address 0. This ensures that every application's memory space is kept separate from each other. If application A accesses memory at address zero, it will not affect application B who has stored information at its address zero. The Mac OS X kernel as well as some specialized hardware in your computer handles translating these virtual addresses into real memory addresses.

    Just because virtual addresses have been allocated, that doesn't mean that they have been used. I could easily write a program that will increase the total VM Size by 2 gigabytes, and not a single byte would be consumed in real memory or on my disk. If my program began to aggressively access those 2 gigabytes of virtual addresses, that would put a strain on the kernel and the computer to map them to real memory -- I only have 768 Megs of real memory. To make room, some stuff in real memory gets 'paged' out to the hard disk. This is were the pagein/pageout count comes from. A page is 2 KB in size, and every time one is written to the disk it increments the pageout counter. Every time one is read back from the disk to be used by an application, the pagein counter is incremented. These numbers do not reset until reboot the entire system, so they don't give a good estimate of how much disk space you are actually using for the pagefiles. Your pageout count could be astronomically high, but that just might be from some memory intensive application that was running for a breif bit.

    To see just how much disk space is being consumed by your page files, look inside the /var/vm/swap folder. It holds the pagefiles. New ones are created on the fly ass needed by the operating system, and old ones are deleted when they aren no longer necessary.
  4. XP Defector thread starter macrumors 6502

    Apr 5, 2006

Share This Page