I was double checking my notes for 'Virtual Memory' and the definition in my text book is:

Process of allocating a section of secondary storage to act as part of the main memory

Where as Wikipedia says:

Virtual memory is a computer system technique which gives an application program the impression that it has contiguous working memory (an address space)

and (Wikipedia also says)

Note that "virtual memory" is more than just "using disk space to extend physical memory size"

Can anyone offer any clarification as to which is correct?

  • I believe the note from Wikipedia involves some qualifications on what is used in terms of things being contiguous.
    – JB King
    Commented Sep 17, 2009 at 19:25
  • This question would probably get a better answer on SO. Commented Sep 17, 2009 at 20:00
  • 2
    Don't confuse what virtual memory is with how it's used. Wikipedia's 1st sentence is defining what it is. Your book is talking about how it's typically used. Once people talk about "pages" they're talking about a specific implementation of virtual memory.
    – Tony Lee
    Commented Sep 17, 2009 at 23:30
  • 2
    Your text book is just plain wrong. There are many machines with virtual memory and no secondary storage at all. Similarly, there once were many machines that could use secondary storage as part of main memory but didn't support virtual memory. "Virtual memory" is something that is not memory but is accessed like memory. Your textbook is defining swapping or paging. Commented Nov 30, 2011 at 0:10
  • 1
    The textbook defines it entirely incorrectly, secondary storage is not part of the definition. And even Wikipedia's statement about "more than disk space" is misleading, because it may not involve disk at all - that statement sounds like it is "extending memory to disk" plus something else.
    – Kelvin
    Commented May 22, 2012 at 19:46

6 Answers 6

Note that "virtual memory" is more than just "using disk space to extend physical memory size"

Virtual memory is a layer of abstraction provided to each process. The computer has, say, 2GB of physical RAM, addressed from 0 to 2G. A process might see an address space of 4GB, which it has entirely to itself. The mapping from virtual addresses to physical addresses is handled by a memory management unit, which is managed by the operating system. Typically this is done in 4KB "pages".

This gives several features:

  1. A process can not see memory in other processes (unless the OS wants it to!)
  2. Memory at a given virtual address may not be located at the same physical address
  3. Memory at a virtual address can be "paged out" to disk, and then "paged in" when it is accessed again.

Your textbook defines virtual memory (incorrectly) as just #3.

Even without any swapping, you particularly need to be aware of virtual memory if you write a device driver for a device which does DMA (direct memory access). Your driver code runs on the CPU, which means its memory accesses are through the MMU (virtual). The device probably does not go through the MMU, so it sees raw physical addresses. So as a driver writer you need to ensure:

  1. Any raw memory addresses you pass to the hardware are physical, not virtual.
  2. Any large (multi page) blocks of memory you send are physically contiguous. An 8K array might be virtually contiguous (through the MMU) but two physically separate pages. If you tell the device to write 8K of data to the physical address corresponding to the start of that array, it will write the first 4K where you expect, but the second 4K will corrupt some memory somewhere. :-(

I'll try to start slowly, and then put this all together for you. It's like this:

Virtual memory, as commonly used, refers to "paging". As the name suggests, paging is like a human notepad.

When you're working out simple sums, or learning simple information, you do it all in your head: you just load up all the information, process it, and get the answer. This is like a computer loading files from the hard drive -- it loads up the programs or pictures or other information it needs to work into its "real memory" (or "physical memory") and works on them with it's "brain" (its processor).

However, when you're learning complex information, or working with complex sums, you might not be able to fit all that in your head at once. You get confused, start to slow down, fail to keep it all in there at once, and have to forget something to remember something else.

The human solution is to use a notepad. We note down on pages all the things we can't remember at once, but refer to them while doing the sums. We might not be able to remember a huge list of sales figures for the month, but we can look at the pages, get the information a bit at a time, and process each bit. This is like the computer "paging" its memory -- writing pages full of information, and putting it into "virtual memory" for later reference, and realising it needs a page, and loading that page back from virtual memory into real memory. On linux and unix, the place where these pages are stored is literally called a "pagefile", and the pages of data in memory are literally called "pages". Different systems have different names for these things, but the general concept is much the same.

So really, paging is very simple. All of the pages of information don't fit in memory, so some pages are put on disk, and loaded again later.

Now, where it gets more complicated is that, modern systems feature memory mapping and memory protection, which is all usually handled by the same hardware system in the computer: the memory management unit, or MMU.

In a (modern) multitasking computer, which can run many programs at once, and features memory protection, each program is usually seperated from other programs running on the same system. This way, one program cannot alter another program simply by accessing its memory -- the MMU physically separates one program's address space from that of others. In other words, user's programs don't see other user's programs or even other programs. They don't see "real memory" -- they see their own "virtual memory".

Now, this memory isolation concept and the pagefile concept are two conceptually different things, which is probably why you're confused. However, the key is that they both work using the MMU -- the memory management unit, which splits memory into pages, and maps pages to a virtual address space.

So, when a program asks for the memory at a certain "memory address", what really happens is that the memory pages for that program and their corresponding addresses (the program's "address space") are looked up, and the page that corresponds to that memory block is found. That page can either be loaded somewhere in real memory, in which case the program is given access, or, it can be paged out to a disk. If it is paged out, then it triggers a "page fault" -- the disk is accessed, and the page gets loaded into memory. So the program works even when there isn't enough memory, but it runs SLOWLY, if it's having to use disk for what would normally be a very fast memory access.

Now, if there isn't enough space to load that page into memory, then you have a problem. In that case, some OTHER page that's already in memory has to be "swapped" to disk, so the first program's page can be loaded. Or, they might equally be pages from the same program. You see this sometimes in graphics programs, for instance, on heavily loaded systems, when part of the picture is loaded slowly and drawn quickly, then the next part is loaded equally slowly and drawn quickly, and when you go back to work with the first part, it's slow AGAIN. That's because they're being loaded in to be worked on, then swapped out again, so something else can be worked on. Obviously, this is a very slow way to work, and what you really need is more REAL memory.

  • I 100% disagree with this answer. If "virtual memory" referred to paging, then a system that doesn't page (say, one with no swap or page files enabled) could not support virtual memory. But that's obviously insane. Commented Aug 28, 2011 at 22:09
  • @DavidSchwartz - I initially had a reaction similar to yours, but in reading the answer in more detail, I don't think it is so bad. Consider Wikipedia/virtual memory/Paged says "Nearly all implementations of virtual memory divide a virtual address space into pages, blocks of contiguous virtual memory addresses". That is, "paging", in the broad sense, does not require a page file, but refers to the mapping of virtual addresses into physical addresses. Commented May 14, 2017 at 10:42
  • 1
    Hmm, on the other hand, Lee says "All of the pages of information don't fit in memory, so some pages are put on disk, and loaded again later.", so David is right: this answer misses the essential fact that paging is not just about paging to disk. On the plus side, Lee does go on to mention other benefits of virtual memory (memory isolation). If this answer were reworded to not muddle "mapping pages of virtual memory" with "paging to disk", it would be more useful. Commented May 14, 2017 at 10:51
  • @ToolmakerSteve The problem is that this is a very common misconception and anything that strengthens that misconception is, IMO, a bad thing. It's especially bad here when this answer is trying to explain the very basic concepts in a very simple matter -- there it's the most important not to lay a groundwork based on a common misconception! Commented May 14, 2017 at 17:35
  • @DavidSchwartz - I agree. You are right, he is not defining "virtual memory", he is defining "how a page file works". At first I had thought that the problem was merely that Lee failed to distinguish between "paging = mapping pages of memory from virtual to physical" versus "page file = mapping pages to disk", but after re-reading, he really was talking only about mapping to disk. (As we can see, from the textbook quote, from all the other answers except the Captain's, and from a google search, this commingling of the two concepts is very widespread. I'm sure I've been guilty of it.) Commented May 19, 2017 at 9:45

I know it’s too late....but thought still it useful.

  • All are correct based on different viewpoints.
  • Virtual memory is a memory management technique whereas swap memory was area on the disk drive. Swap memory is generally called as swap space. Swap space refers to the portion of the virtual memory which is reserved as a temporary storage location. Swap space is utilized when available RAM is not able to meet the requirement of the system’s memory
  • You can refer to the below link for more details

Well if we understand the word virtual I think we can understand how it relates to memory.

"Virtual" as defined on Dictionary.com: "temporarily simulated or extended by computer software: a virtual disk in RAM; virtual memory on a hard disk."

In the case of Virtual Memory, the system is simulating system memory by using slower memory resources (i.e. hard drive, thumb drive etc..) When additional memory is required the system will swap out data in system memory which is not needed to the hard drive or resource you have setup. This frees up system memory so that your application can continue the task it was doing.

The swapping is a continuos process and thus if you upgrade your memory you should see a performance improvement as the system should not require swapping to slower memory as offten.


Virtual memory is a feature of an operating system (OS) that allows a computer to compensate for shortages of physical memory by temporarily transferring pages of data from random access memory (RAM) to disk storage.

Meaning it is like a mirror or a sample memory that is used in virtual machine or virtual box to try Operating systems without formatting the computer.

  • Nope, that's paging. Commented Nov 25, 2015 at 10:00

Virtual Memory is a block of your hard Drive that the system uses as a paging file in addition to the physical RAM.

It gets tricky, and sometimes slow, because Windows does NOT defrag this part of your hard drive.

Best 2 tips I can offer: 1) Virt Mem should be set both min and max at approx 1.5X your physical Memory. ex. 2GB RAM = 3070MB Virt. 2) When defragging, turn off your paging file. Defrag 2x, and reset back to the original number. This gives a clean slice of drive and will increase the speed of the paging file.

  • 1
    That's not completely true - modern memory managers virtualize ALL the system memory. This is what allows for process separation - each process can only touch its own memory. The memory manager is responsible for mapping these virtual pages to the real storage, and optionally to a fixed disk. Commented Sep 17, 2009 at 19:31
  • 1
    "Windows does NOT defrag this part of your hard drive." simply nuke pagefile.sys, reboot, defrag the disk and re-enable paging, voilá, a fresh and contigeous pagefile! however, Sysinternals' PageDefrag does a better job as it will also place the pagefile at the beginning of the drive/partition for better performance.
    – Molly7244
    Commented Sep 17, 2009 at 19:34
  • 1
    If this answer were correct, then a Windows system with no page files configured couldn't provide any virtual memory support. But this is obviously wrong. Such a system could still, for example, map files into process address space in excess of physical RAM, which is an example of virtual memory. Commented Aug 28, 2011 at 22:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .