1. terms for memory

physical memory: it is physical object which costed your money to
install it into your PC. the capacity depends on what you purchased.

virtual memory: it is not physical. it is not a file in operating
system. it only exists in logic. it is a conception. the size, a.k.a.,
address space, depends on your cpu architecture (x86, x64 or i64, etc.).

page file: it is not physical, but it is a file in operating
system. the size can be changed by a system wide setting.

(some Chinese engineers confuse ‘virtual memory’ with ‘page file’ because of the translation. if you
discuss with them, you’d better make sure what you are discussing about.)

2. the relationships

when a process is launching, it needs to allocate memories. it allocates memories
from its own address space, a.k.a. virtual memory, regardless which
function (new, VirtualAlloc, etc.) was called.

when cpu executes a process and want to access a memory block which
has been allocated from virtual memory, it needs the memory block in
physical memory. if there is no free space for the block in physical
memory, os will move some unused blocks from physical memory to page
file. so, os will do those things:
a.) mapping virtual memory to physical memory
b.) move unused memory block from physical memory to page file/files
c.) move needed memory block from page file/files to physical memory
3. terms for virtual memory
1.) page
we used ‘page’ in page file, but there is another term ‘page’ related
to virtual memory. while allocating from virtual memory, the minimum
unit is a page. a page has three states:

a.) free
b.) reserved
c.) committed

free, this is easy to understand, the page hasn’t been allocated.
reserved, the page has been allocated, but has been committed.
committed, the page has been mapped into physical memory.

2.) working set
working set is a set, a container. it collects a set of pages in the
virtual memory of a process, and the pages currently resident in
physical memory.
working set has a minimum size and a maximum size, which can be set by
SetProcessWorkingSetSize.

Above is a simple introduction to the terms used to refer memory. For
further study, please refer to msdn.

Comments

2010-02-08