4

I know virtual memory is a paging file that computer uses to store a part of RAM on hard disk for a running process. But how different is Virtual address space? is it the RAM or hard disk or both?

2
  • 4
    Virtual memory is NOT just "a paging file". You're still using virtual memory even if you don't have a pagine file. Commented Sep 3, 2015 at 18:05
  • 1
    There are systems with virtual memory and no paging file (such as most SoHo routers) and systems with paging files and no virtual memory (paging files were used on many early computers that had no support for virtual memory). This is common misconception. Commented Nov 23, 2015 at 8:23

3 Answers 3

8

The virtual address space is what an individual program sees when it executes. Depending on how the program has been configured this address space will be as large as the maximum the operating system supports.

The operating system kernel is then responsible for mapping addresses in the vas to physical memory, be that RAM, or system page files.

With this design, the programs themselves remain unaware of resources and real addresses, and can operate as if they had all system memory to themselves, or at least the maximum memory a single process can use.

In a nutshell a program works with VAS, and the operating system handles mapping VAS to real storage so that this is invisible to the running program. The running program sees only its VAS.

0

Virtual Address Space is a limitation on the size of memory a program can address.

This is constrained at the outer bound by the style of pointers - a pure 32bit pointer can in theory address 4GB of virtual space. The real bound is dependent on operating system design as it uses a significant part of the address space alongside the user space.

Under Win32, the default setting is to allow virtual address space of 2GB as user space.

A 64bit pointer can address far more, in practice typically 48bits are allowed and there's lots of details on this superuser answer.

In theory, someone could build a physical computer with enough RAM that that 2GB of user space could be directly mapped to physical memory (probably needing at least 3GB of physical) so you would have 32bit processes where the virtual memory wasn't very virtual.

1
  • 2gb of user space only needs 2GB of physical memory. The 2GB limit is so much due to OS design, but more due to the fact that pointers in C/C++ are signed into by default.
    – surfasb
    Commented Nov 23, 2015 at 15:15
-1

Virtual address space is what the process sees. For example, your email sits in an inbox that is, say, 25GB in size. That is your virtual address space.

Virtual address space is to distinguish the fact that not every virtual address space corresponds to a physical address space. Lets say you have 20 email users with 25GB of inbox space. But you only have 100GB of disk space on your server. Well, you can take old emails and archive them and only keep the recent ones on your server because people usually only check the most recent email.

Archiving email from the server to, say, a tape drive is akin to the computer paging parts of RAM to disk. When someone goes to look at old email, you just "page" the old email from the tape back onto your server. The email user will never know the difference.

In the same way, each process on your machine has X virtual address space, even though you may have less than X * number of processes of physical memory.

Virtual memory is exactly that. Virtual address space. But virtual memory is just the virtual address space that you are using.

7
  • This is comprehensively wrong.
    – Andy Dent
    Commented Nov 23, 2015 at 7:51
  • Really? Please explain...
    – surfasb
    Commented Nov 23, 2015 at 15:16
  • The size of a 25GB inbox on disk has nothing at all to do with virtual address space. There's a very straightforward definition of it and I get that you were trying to use an analogy. A lot of people reading your answer, who don't already know what virtual address space is, would not realise it's purely an analogy.
    – Andy Dent
    Commented Nov 23, 2015 at 17:12
  • 1
    "Virtual memory is just the virtual address space that you are using." NO it is not. Virtual address space is the space your program can address in theory, as a combination of the pointer size restrictions and the OS restrictions.
    – Andy Dent
    Commented Nov 23, 2015 at 17:13
  • I think it is a very good analogy considering most people reading the answer are coming from the space of "what does virtual memory and virtual memory address space mean to me as a average user". Now if this is stackoverflow, then this analogy would not suffice and the question itself would need more context. Keep in mind this is Superuser, not Device Driver programmers group.
    – surfasb
    Commented Nov 23, 2015 at 20:42

You must log in to answer this question.

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