Well I think I can answer some of those questions,
though I'm not a Windows memory architecture expert
and can't precisely explain the way it decides to do
paging / pooling / address mapping.
A 32 bit operating mode processor under Windows
runs in a paged virtual memory configuration.
The virtual address space of the 32 bit processor is
in general approximately 32 bits worth,
2^32 = 4 gigabytes addressable from addresses
0x00000000 to 0xffffffff, i.e. every possible 32 bit
address number.
So in that way you always have a 4GB (approximately)
virtual *address space* to work with, that doesn't mean
that you can *USE* it all though depending on the actual
amount of physical RAM and amount of demand paging
secondary storage you have configured (e.g. page files).
You say windows 32 allocates 2GB address space for
system / kernel use and 2GB address space for
application use. I've heard things like that before and
doubtlessly have concrete references to the details but
don't recall them.
It's not terribly important just how it does it unless you're
writing code that has to use a lot of memory inside an
application or are writing certain kinds of system code.
Actually as you can have a large number of task / page
descriptors you can (in the 32 bit processor limitation,
saying nothing about windows) have lots and lots of
independent tasks each with a potentially independent
and non-overlapping 4GB address space of their very own.
When you context switch to a given task context you
basically reload the MMU's Physical to Virtual memory
mapping tables and page protetection tables etc. so
the actual memory map active for a given task can be
anything, and of course the kernel has the opportunity
to completely reconfigure the *contents* of physical
and virtual memory as well as I/O before switching tasks
so basically there is something closer to an infinite amount
of "virtualized" storage available just depending on how
the kernel allocates PM and the 4GBy of VM to each task.
Anyway windows apparently keeps 2GB of VM mapped for
task related uses and 2GB VM mapped into a task's address
space for system controlled shared memory / IO areas
etc. etc. PAE mode may change the details a bit, as well
as if you're running 16 bit compatibility mode or DOS
compatibility mode tasks, etc. etc.
Anyway demand paging takes advantage of the fact that
whenever a piece of memory is requested the 32 bit
address is divided into two parts, the upper bits specifying
a page number, and the lower few bits specifying an
address within the page. Typically pages are 4 kilobytes,
though depending on your architecture and OS the
number can vary.
The page number is looked up in a page table
which contains bits like security information
on whether the page is readable, writable, executable,
resident, non-resident, clean, dirty, who owns it,
etc. If there's a security problem relating to a task
accessing a page an exception is raised and system
code is invoked to handle the situation before the
task instruction that was trying to access the memory
is even completed. The system can then decide what
the "result" of the memory access should be.
Similarly when a memory page is marked "non resident"
i.e. not actually available in memory, any access attempt
to it generates an exception interrupting the requesting
task's access instruction in mid-execution.
System code and the system can then handle that exception
by choosing to load that page's data into physical RAM
(e.g. from a disk copy of the page) and then continue the
access instruction as if nothing ever happened (except
a long actual delay as the memory was loaded from disc
and the page remarked "resident" by the system).
So basically a few of your questions seem to be answered
by noting that the system may always have/provide
those 4GB / 2GB virtual address *spaces* for each
task, the actual available amount of physical memory
may be far less than 2GB, and furthermore the amount
of page storage available in the page file may also be
less than even 2GB.
This doesn't mean that you must have at least 2GB of
RAM or at least 2GB of page file or RAM+pagefile >= 2GB.
It just means that it'll quit trying to allow more "active"
memory pages from being created once you reach the
limit of your physical RAM, and it'll quit allowing more
"demand paged" memory pages from being created
once your physical RAM and pagefile storage capacity
are exhausted.
Even with 256MB RAM and 1GB page file the kernel will
still have a 2GB virtual address space and the
application will too, but no more than 1.25 GB will actually
ever be available to the combined uses of the system
in such a case. Extending the size of the page file out to
some larger number will allow more virtual memory to be
taken advantage of, but it's rarely beneficial to have
much more actively used virtual memory than physical
RAM since the VM disk paging will be millions of times
slower than the physical RAM. So the programs using it
will still operate transparently not knowing they're
causing memory paging while they go through memory
calculating, but the result will become untenably slow in
many cases once you start paging to disk very often.
Originally posted by: kimchee411
Hi all,
I'm writing up some documentation on how to troubleshoot an error we've been having with our servers pertaining to EID 2019 System nonpaged pool depletion, and I'm trying to explain what pool is for some background info, but I'm a little unclear myself...
First question: What is the relationship between pagefile and pool?
I've read time and time again that Windows always has 4GB of address space - 2 to apps and 2 to system no matter how much RAM the system has, but how would the system page out, let's say 2 GB, if the pagefile is smaller than that?
And disk space? If you have a 2 GB hard drive and 256 MB RAM, would the pool size/address space still be 4 GB? What would happen if 3 different applications, in theory, tried to utilize a full 2 GB of address space each? I don't understand how that could be if your page file is like 384 MB + the 256 MB of physical RAM.
Would page faults occur until the necessary resources are freed? Wouldn't this mean we should always have at least a 4 GB pagefile?
Pardon my crude understanding and probably poor wording. I can't find these answers via Google.
Thanks in advance!