Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


November 1997

Windows NT Paging Fundamentals


RSS
Subscribe to Windows IT Pro | See More Internals and Architecture Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Understanding NT's concept of memory management

If you've poked around in your system settings, you've probably seen the "paging file." You probably know that the paging file is the main on-disk repository for data that your programs need access to, but not necessarily right now. Somehow, Windows NT decides which data goes into the paging file and which data resides in physical memory.

There's a little more to it than that, however. In this article, I'll describe how this paging file works, what it does, and why you need it. First, I'll explain some basic concepts and structures associated with paging, and then I'll explore how paging and physical memory work together to affect your system's performance.

Virtual vs. Physical
When you refer to memory use under NT, it's important to know whether you're referring to physical memory or virtual memory. Physical memory is an easy concept to grasp--it's the amount of RAM installed on your system. Virtual memory, however, has nothing to do with the amount of physical memory installed but is the amount of memory that the operating system and the applications you're running perceive to be available: 4GB for each application. The amount of physical memory does not affect the amount of virtual memory available to each program. Whether your computer has 16MB or 600MB of RAM, each program will have 4GB of virtual memory.

Why 4GB of virtual memory? Because NT uses a 32-bit binary addressing scheme (i.e., each address in virtual memory has 32 bits), and 232 is equal to 4GB. Future versions of NT that use an addressing scheme with more bits will support an even larger virtual memory area.

The 4GB of virtual memory addresses available to each program are divided between user space and system space. User space, using the lower addresses, is private to each 32-bit program, and other programs ordinarily cannot manipulate it; 16-bit applications made for previous versions of Windows share a single address space, unless you specify otherwise at program startup. (If two 32-bit programs have a shared memory area set up, they can read and write to the data in each other's user address space, but this situation is the exception, rather than the rule.) System space, using the upper addresses, is common to all programs running on the system and to all components of the operating system. It's used for structures that all programs need access to.

Be aware that NT 4.0 divides the virtual addresses evenly between the user and system areas, providing 2GB of space for each. Adding Service Pack 3 (SP3) and running NT Enterprise Edition mean that you can boot NT 4.0 on an x86 system with a 3GB user address space, leaving 1GB for system space. NT 5.0 will always use the 3GB/1GB split for user addresses and system addresses.

Among the structures stored in system space are those used to translate between virtual and physical addresses. Translation? Well, yes: NT physically stores data into RAM, but all programs refer to virtual addresses, not physical ones. Translation between the two is necessary so that, for example, when a program requests the data stored at virtual address 2000000, it gets the data stored in physical address 45h.

Page Faults
What if a program requests data stored at virtual address 2000000, but no physical address is currently storing that data? This turn of events is fairly common, particularly when a program is just starting up, because NT starts applications with the least amount of memory necessary. In this case, an exception called a page fault occurs.

Unlike some other NT exceptions, a page fault isn't dire--it's simply how the operating system alerts itself that it can't do something that it's been directed to do under current circumstances, and other action is required. This exception is equivalent to you getting in your car without your car keys and realizing that you can't start the car without first getting out, retrieving the keys from the side table where you left them, and getting back in the car. This glitch doesn't mean your car won't start, but that you need to do something before it will.

NT's Virtual Memory Manager is responsible for handling page faults. The Virtual Memory Manager loads data into a physical memory address that can be translated into a virtual address for the sake of the process.

Page faults are normal occurrences: Except for the minimum needed to get a program going, no data is loaded into memory for the program. This method is NT's way of keeping memory usage to a minimum, ensuring that no application occupies physical memory that it doesn't need. Paging data into memory takes more time than just retrieving data from a physical memory address, but paging is a necessary part of the virtual memory system and better for system performance than forcing all program data to be locked into memory.

Working Sets
When a piece of a program's data is faulted into physical memory, it becomes part of that program's working set. A working set is not the minimum amount of data a program needs to function, nor the maximum, but simply the data that the program happens to be working with at the moment. Broadly speaking, a program's working set is a measure of the amount of physical memory that the program is using. This measure is only an approximate count, because some data included in the working set may be shared among several processes (DLLs are a common example), but that situation is typical of the relationship between working set and physical memory usage.

Working sets will grow and shrink depending on the demand for physical memory. A system thread called the balance set manager is responsible for taking data out of the working set if it hasn't been used for a while. If a serious demand for physical memory arises, the balance set manager may in fact trim every program's working set to a bare minimum (a value established at the time the program was started), requiring programs to fault pages back into memory as required.

   Previous  [1]  2  Next 


Top Viewed ArticlesView all articles
CES 2009: Ballmer Announces Windows 7, Windows Live, Live Search Milestones

During his first-ever Consumer Electronics Show (CES) 2009 keynote address last night in Las Vegas, Microsoft CEO Steve Ballmer announced the pending public availability of a feature-complete Windows 7, the final version of Windows Live Essentials, and ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

Where is Microsoft NetMeeting in Windows XP?

...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Cloud Computing Forum: Integrating Software, Server and Storage as a Service into Your Enterprise IT Delivery Model

Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing