本文包含有關虛擬記憶體實作，在 32 位元版本的 Windows 中的基本資訊。 這項資訊是有關 Windows 2000、 Windows XP，Windows Server 2003，Windows Vista 和 Windows Server 2008。 (因為 Windows Server 2008 R2 只能在 64 位元版本中使用所以此資訊並不會套用至該)。
現代的作業系統來說，例如 Windows、 應用程式和許多系統處理程序中永遠
參考所使用的虛擬記憶體位址的記憶體。 真正的 (RAM) 位址來自動轉譯虛擬記憶體位址的硬體。 只有核心部分作業系統核心略過此位址轉譯，並直接使用實際的記憶體位址。
永遠正在使用虛擬記憶體，甚至時所需的所有正在執行的處理程序的記憶體不會超過系統安裝的 RAM 數量。
使用 Bruce Sanderson Windows 部落格上的這份文件的擴充的版本。 若要到這份文件，請造訪下列的部落格網站：
處理程序] 和 [地址空間
在 32 位元版本的 Windows 下執行的所有處理 (比方就說應用程式執行檔) 會被都指派虛擬記憶體位址 (a虛擬位址空間
)，範圍從 0 到 4294967295 (2 * 32-1 = 4 GB)，多少 RAM 不論實際安裝在電腦上。
In the default Windows configuration, 2 gigabytes (GB) of this virtual address space are designated for the private use of each process, and the other 2 GB is shared between all processes and the operating system. Typically, applications (for example, Notepad, Word, Excel, and Acrobat Reader) use only a fraction of the 2 GB of private address space. The operating system assigns RAM page frames only to those virtual memory pages that are being used.
Physical Address Extension (PAE) is the feature of the Intel 32-bit architecture that expands the physical memory (RAM) address to 36 bits. PAE does not change the size of the virtual address space (which remains at 4 GB), but just the volume of actual RAM that can be addressed by the processor. 如需詳細資訊，請按一下下列的文件編號，檢視 「 Microsoft 知識庫 」 中的文件：：
Intel Physical Addressing Extensions (PAE) in Windows 2000
The translation between the 32-bit virtual memory address that is used by the code that is running in a process and the 36-bit RAM address is handled automatically and transparently by the computer hardware according totranslation tables
that are maintained by the operating system. Any virtual memory page (32-bit address) can be associated with any physical RAM page (36-bit address).
The following list describes how much RAM the various Windows versions and editions support (as of May 2010):
|Windows NT 4.0||4 GB|
|Windows 2000 Professional||4 GB|
|Windows 2000 Standard Server||4 GB|
|Windows 2000 Advanced Server||8 GB|
|Windows 2000 Datacenter Server||32 GB|
|Windows XP Professional||4 GB|
|Windows Server 2003 Web Edition||2 GB|
|Windows Server 2003 Standard Edition||4 GB|
|Windows Server 2003 Enterprise Edition||32 GB|
|Windows Server 2003 Datacenter Edition||6 GB|
|Windows Vista||4 GB|
|Windows Server 2008 Standard||4 GB|
|Windows Server 2008 Enterprise||64 GB|
|Windows Server 2008 Datacenter||64 GB|
|Windows 7||4 GB|
RAM is a limited resource, whereas for most practical purposes, virtual memory is unlimited. There can be many processes, and each process has its own 2 GB of private virtual address space. When the memory being used by all the existing processes exceeds the available RAM, the operating system moves pages (4-KB pieces) of one or more virtual address spaces to the computer’s hard disk. This frees that RAM frame for other uses. In Windows systems, these “paged out” pages are stored in one or more files (Pagefile.sys files) in the root of a partition. There can be one such file in each disk partition. The location and size of the page file is configured inSystem Properties
Users frequently ask "how big should I make the pagefile?" There is no single answer to this question because it depends on the amount of installed RAM and on how much virtual memory that workload requires. If there is no other information available, the typical recommendation of 1.5 times the installed RAM is a good starting point. On server systems, you typically want to have sufficient RAM so that there is never a shortage and so that the pagefile is basically not used. On these systems, it may serve no useful purpose to maintain a really large pagefile. On the other hand, if disk space is plentiful, maintaining a large pagefile (for example, 1.5 times the installed RAM) does not cause a problem, and this also eliminates the need to worry over how large to make it.
Performance, architectural limits, and RAM
On any computer system, as the load increases (the number of users, the volume of work), performance decreases, but in a nonlinear manner. Any increase in load or demand, beyond a certain point, causes a significant decrease in performance. This means that some resource is in critically short supply and has become a bottleneck.
At some point, the resource that is in short supply cannot be increased. This means that anarchitectural limit
has been reached. Some frequently reported architectural limits in Windows include the following:
- 2 GB of shared virtual address space for the system (kernel)
- 2 GB of private virtual address space per process (user mode)
- 660 MB of system PTE storage (Windows Server 2003 and earlier)
- 470 MB of paged pool storage (Windows Server 2003 and earlier)
- 256 MB of nonpaged pool storage (Windows Server 2003 and earlier)
This applies to Windows Server 2003 specifically, but this may also apply to Windows XP and to Windows 2000. However, Windows Vista, Windows Server 2008, and Windows 7 do not all share these architectural limits. The limits on user and kernel memory (numbers 1 and 2 here) are the same, but kernel resources such as PTEs and various memory pools are dynamic. This new functionality enables both paged and nonpaged memory. This also enables PTEs and session pool to grow beyond the limits that were discussed earlier, up to the point where the whole kernel is exhausted.
Frequently found and quoted statements such as the following:
With a Terminal Server, the 2 GB of shared address space will be completely used before 4 GB of RAM is used.”
This may be true in some cases. However, you have to monitor your system to know whether they apply to your particular system or not. In some cases, these statements are conclusions from specific Windows NT 4.0 or Windows 2000 environments and do not necessarily apply to Windows Server 2003. Significant changes were made to Windows Server 2003 to reduce the probability that these architectural limits will in fact be reached in practice. For example, some processes that were in the kernel were moved to non-kernel processes to reduce the memory used in the shared virtual address space.
Monitoring RAM and virtual memory usage
Performance Monitor is the principle tool for monitoring system performance and for identifying the location of the bottleneck. To start Performance Monitor, click啟動
, and then double-clickPerformance Monitor
. Here is a summary of some important counters and what they tell you:
- Memory, Committed Bytes: This counter is a measure of the demand for virtual memory.
This shows how many bytes were allocated by processes and to which the operating system has committed a RAM page frame or a page slot in the pagefile (or perhaps both). AsCommitted Bytesgrows greater than the available RAM, paging will increase, and the pagefile size that is being used will also increase. At some point, paging activity starts to significantly affect performance.
- Process, Working Set, _Total: This counter is a measure of the virtual memory in "active" use.
This counter shows how much RAM is required so that the virtual memory being used for all processes is in RAM. This value is always a multiple of 4,096, which is the page size that is used in Windows. As demand for virtual memory increases beyond the available RAM, the operating system adjusts how much of a process's virtual memory is in its Working Set to optimize available RAM usage and minimize paging.
- Paging File, %pagefile in use: This counter is a measure of how much of the pagefile is actually being used.
使用此計數器以判定分頁檔是否為適當的大小。 如果這個計數器到達 100，分頁檔皆與項目將會停止運作。 取決於您的工作負載的 volatility，您可能希望分頁檔大足夠讓通常是使用不超過 50-075%。 如果正在使用的分頁檔，有一種以上不同的實體磁碟上可以改善執行效能。
- Memory, Pages/Sec: This counter is one of the most misunderstood measures.
A high value for this counter does not necessarily imply that your performance bottleneck stems from a shortage of RAM. The operating system uses the paging system for purposes other than swapping pages because of memory over-commitment.
- Memory, Pages Output/Sec: This counter shows how many virtual memory pages were written to the pagefile to free RAM page frames for other purposes each second.
This is the best counter to monitor if you suspect that paging is your performance bottleneck. Even ifCommitted Bytesis greater than the installed RAM, if Pages Output/sec is low or zero most of the time, there is no significant performance problem from insufficient RAM.
- Memory, Cache Bytes,
Memory, Pool Nonpaged Bytes,
Memory, Pool Paged Bytes,
Memory, System Code Total Bytes,
Memory, System Driver Total Bytes:
The sum of these counters is a measure of how much of the 2 GB of the shared part of the 4-GB virtual address space is actually being used. Use these to determine whether your system is reaching one of the architectural limits discussed that were discussed earlier.
- Memory, Available MBytes: This counter measures how much RAM is available to satisfy demands for virtual memory (either new allocations, or for restoring a page from the pagefile).
When RAM is in short supply (for example, Committed Bytes is greater than installed RAM), the operating system will try to keep a certain fraction of installed RAM available for immediate use by copying virtual memory pages that are not in active use to the pagefile. Therefore, this counter will not reach zero and is not necessarily a good indication of whether your system is short of RAM.
For more information about these subjects, visit the following Microsoft websites and blog sites: