views:

58

answers:

3

I have virtual memory size set to 756 MB on windows xp. but when reading on msdn it says virtual memory for each process on 32 bit OS is 4 GB by default. how it is different from the size of virtual memory that i set?

**Memory**      **range**                    **Usage**
Low 2GB (0x00000000 through 0x7FFFFFFF)  Used by the process.
High 2GB (0x80000000 through 0xFFFFFFFF)    Used by the system.

also, how is the range is same for each process?

+1  A: 

The virtual memory setting in windows only affect the size of the virtual memory paging file, not the total size of virtual memory allocated to processes.

ennuikiller
+3  A: 

Your page file is set to 756 Mb. The page file is like extra RAM, but backed by the disk.

Virtual Memory, however, is different, and kind of complex.

Every process gets an address space of 4 Gb. This is the range of a 32-bit pointer, so that' works out nicely. Half of that is reserved for the Kernel (Operating System), and is the same in every process. The other half is for the process itself, and is unique to that process.

The operating system allocates "pages" to the private portion of memory as the process asks for it. The pages get a slot in the process's address space which has nothing at all to do with where they are in physical RAM. In fact, they may not even be in RAM if they're not currently being used. The operating system will "swap" pages out to the page file if it wants some physical RAM for something else.

An important thing to remember is that address 0x10000 in your process is totally different from 0x10000 in another process.

Fortunately, the operating system juggles all this around so you don't have to.

Mike Caron
+1  A: 

This is way too big a subject to cover adequately in an answer here. You almost certainly need to read a book (I recommend Jeffrey Richter's books for this kind of subject matter).

The 4 Gb is about address space. The 756 Mb is about backing store.

Quite a few things (especially the contents of executable files) use address space without using backing storage. When you execute a program, the executable file for that program (and all the DLLs it uses) are mapped to address space. Then, on a page-by-page basis, pieces of that executable are brought into physical memory as needed.

The 756 Mb is extra storage to "extend" the RAM space -- but this is normally used only for data, not code; code is already stored in the executable file, so the system reads the data directly from the executable file when it's needed. The 756 Mb is used primarily for data you've created or modified as the computer is running (though the definition of "modified/created" can be fuzzy -- for example, the contents of a web page you've loaded would be included because you caused it to come into memory, even though you didn't create it or change it at all).

Jerry Coffin