1.3.1 Memory States
An appreciation of NT memory architecture is crucial to the understanding of LeapHeap.
NT recognises three states of memory (these are given various names by different authors).
- Address range
- An NT process has available 2 GB of address range (top-end platforms allow more).
When the process starts, some of this memory is claimed for code and static data.
Thereafter the application may freely allocate the remainder. Allocating address
range is fast because it is merely a bookkeeping operation.
- Pagefile memory
- A portion of address range may be turned into 'real' memory by committing it.
Committing memory reserves space in the NT paging file. Pagefile memory is the
resource in short supply when you see the familiar popup: Your system is running low
on virtual memory... The size of the paging file limits the aggregate committed memory
of all running processes on a machine.
- Random Access Memory
- For application code to read or write an address, the 4 KB (one kilobyte
is two to the power 10 bytes) memory page that contains
the address must be present in RAM. If it is not, the thread executing
the code blocks while the content of the whole page is copied from the paging file (or an executable
file) into RAM. That event constitutes a page fault.
The rationale for LeapHeap may be summarised as three assertions:
- Address range is free
- Pagefile memory is cheap
- RAM is expensive
The first assertion does not hold for all applications, because we are nearing the
end of the 32-bit generation of processors. Originally the available 2 GB (half the total
address space is reserved for operating system use) was an unimaginable feast of memory.
Today we find machines fitted with comparable amounts of RAM, and a few big-iron
applications can exhaust the address range. LeapHeap can be used with such applications,
but needs to be tuned to them as described in section 6.3 Tuning.
Windows NT allows a paging file of up to 2 GB on each hard drive, and the drives
need not even be physically distinct. With modern disc capacities, there should be no problem
providing as much pagefile memory as required, partitioning discs as necessary.
Of the three memory types, it is the quantity of RAM fitted to a machine that almost
always limits application performance.