How Windows NT Provides 4 Gigabytes of Memory (99707)
The information in this article applies to:
- Microsoft Windows NT Server 3.1
- Microsoft Windows NT Workstation 3.1
This article was previously published under Q99707 SUMMARY
Windows NT has an addressable memory space of four gigabytes. This is
considered a virtual memory space as most computers do not have the
physical RAM to actually contain four gigabytes of data. Because of
the services provided by the Windows NT virtual memory manager,
programs can be written to exploit large amounts of memory without
being concerned with the type of memory or the amount available. The
Windows NT virtual memory manager provides this large, virtual memory
space to applications via two memory management processes: moving data
between physical RAM and the hard disk or paging, and translating
physical memory addresses to virtual memory addresses or mapped file
I/O.
MORE INFORMATIONPAGING
When a file is larger than the size of your available system RAM, the
virtual memory manager uses paging to move data between RAM and the
hard disk. It accomplishes this by dividing all physical memory and
virtual memory (the memory used by applications) into equal sized
blocks or pages (4K each). When a request is made to access data that
is not in RAM, the virtual memory manager swaps a page from RAM with
the desired page from the paging file (a file on the hard disk used
solely by the virtual memory manager for extra data storage).
Page states are registered in a virtual page table. If a page is in
RAM and is immediately available to its process (or program), it is
marked as valid. Pages that have been moved to the paging file are
marked as invalid. When a process tries to access an invalid page, the
central processing unit (CPU) generates a page fault. The virtual
memory manager traps page faults and retrieves pages from the paging
file. If there is no room in RAM to store a new page, a valid page is
moved out.
PAGING POLICIES
There are three policies used by the virtual memory manager to
determine how and when paging is performed:
Fetch
A demand-based paging algorithm is used to retrieve (or fetch) memory
pages. The virtual memory manager waits until a process thread
attempts to access an invalid page before loading the page into RAM.
Because page faults and disk access are both somewhat slow, additional
pages are loaded along with the desired page in a process called
clustering. The additional pages are chosen by their proximity to the
desired page, the theory being that the process may need information
that spans several consecutive pages. This reduces the number of page
faults generated and the amount of disk operations.
Placement
Placement refers to the location a page is stored in RAM. The virtual
memory manager chooses the first free page in RAM it finds.
Replacement
If the placement policy fails because there are no free pages in RAM,
the replacement policy is used to determine which page will be moved
from RAM to the paging file. Each process has a group of valid pages
in RAM; these are called the working set. For simplicity, a first-in,
first-out (FIFO) algorithm is used. When a page replacement is
required, the oldest page in the working set is moved to the paging
file to make room for the new page. Because the replacement scheme is
only applied to the working set of the current process, other
processes are guaranteed that their pages will not be replaced by
other processes.
MAPPED FILE I/O
If an application attempts to load a file that is larger than both the
system RAM and the paging file combined, the mapped file I/O services
of the virtual memory manager are used. Mapped file I/O enables the
virtual memory manager to map virtual memory addresses to a large
file, inform the application that the file is available, and then load
only the pieces of the file that the application actually intends to
use. Because only portions of the large file are loaded into memory
(RAM or page file), this greatly decreases file load time and system
resource drainage. This is a very useful service for database
applications that often require access to huge files.
Modification Type: | Major | Last Reviewed: | 11/4/2003 |
---|
Keywords: | KB99707 |
---|
|