Brian Madden Logo
Your independent source for application and desktop virtualization.
Marketplace

advertisement
Brian Madden's Blog

The 4GB Windows Memory Limit: What does it really mean?

Written on Feb 19 2004 318,971 views, 161 comments


by Brian Madden

[Note from Brian Madden on March 24, 2004: Since I originally posted this article, I received some corrections from David Solomon, author of the book "Inside Windows 2000." (Thanks David!) I've since rewritten some portions of this article to incorporate his corrections.]

There seems to be a lot of confusion in the industry about what's commonly called the Windows “4GB memory limit.” When talking about performance tuning and server sizing, people are quick to mention the fact that an application on a 32-bit Windows system can only access 4GB of memory. But what exactly does this mean?

By definition, a 32-bit processor uses 32 bits to refer to the location of each byte of memory. 2^32 = 4.2 billion, which means a memory address that's 32 bits long can only refer to 4.2 billion unique locations (i.e. 4 GB).

In the 32-bit Windows world, each application has its own “virtual” 4GB memory space. (This means that each application functions as if it has a flat 4GB of memory, and the system's memory manager keeps track of memory mapping, which applications are using which memory, page file management, and so on.)

This 4GB space is evenly divided into two parts, with 2GB dedicated for kernel usage, and 2GB left for application usage. Each application gets its own 2GB, but all applications have to share the same 2GB kernel space.

This can cause problems in Terminal Server environments. On Terminal Servers with a lot of users running a lot of applications, quite a bit of information from all the users has to be crammed into the shared 2GB of kernel memory. In fact, this is why no Windows 2000-based Terminal Server can support more than about 200 users—the 2GB of kernel memory gets full—even if the server has 16GB of memory and eight 3GHz processors. This is simply an architectural limitation of 32-bit Windows.

Windows 2003 is a little bit better in that it allows you to more finely tune how the 2GB kernel memory space is used. However, you still can't escape the fact that the thousands of processes from hundreds of users will all have to share the common 2GB kernel space.

Using the /3GB (for Windows 2000) or the /4GT (for Windows 2003) boot.ini switches is even worse in Terminal Server environments because those switches change the partition between the application memory space and kernel memory space. These switches gives each application 3GB of memory, which in turn only leaves 1GB for the kernel—a disaster in Terminal Server environments!

People who are unfamiliar with the real meaning behind the 4GB Windows memory limit often point out that certain versions of Windows (such as Enterprise or Datacenter editions) can actually support more than 4GB of physical memory. However, adding more than 4GB of physical memory to a server still doesn't change the fact that it's a 32-bit processor accessing a 32-bit memory space. Even when more than 4GB of memory is present, each process still has the normal 2GB virtual address space, and the kernel address space is still 2GB, just as on a normal non-PAE system.

However, systems booted /PAE can support up to 64GB physical memory. A 32-bit process can "use" large amounts of memory via AWE (address windowing extension) functions. This means that they must map views of the physical memory they allocate into their 2GB virtual address space. Essentially, they can only use 2GB of memory at a time.

Here are more details about what booting /PAE means from Chapter 7 of the book "Inside Windows 2000," by David Solomon and Mark Russinovich.

All of the Intel x86 family processors since the Pentium Pro include a memory-mapping mode called Physical Address Extension (PAE). With the proper chipset, the PAE mode allows access to up to 64 GB of physical memory. When the x86 executes in PAE mode, the memory management unit (MMU) divides virtual addresses into four fields.

The MMU still implements page directories and page tables, but a third level, the page directory pointer table, exists above them. PAE mode can address more memory than the standard translation mode not because of the extra level of translation but because PDEs and PTEs are 64-bits wide rather than 32-bits. The system represents physical addresses internally with 24 bits, which gives the x86 the ability to support a maximum of 2^(24+12) bytes, or 64 GB, of memory.

As explained in Chapter 2 , there is a special version of the core kernel image (Ntoskrnl.exe) with support for PAE called Ntkrnlpa.exe. (The multiprocessor version is called Ntkrpamp.exe.) To select this PAE-enabled kernel, you must boot with the /PAE switch in Boot.ini.

This special version of the kernel image is installed on all Windows 2000 systems, even Windows 2000 Professional systems with small memory. The reason for this is to facilitate testing. Because the PAE kernel presents 64-bit addresses to device drivers and other system code, booting /PAE even on a small memory system allows a device driver developer to test parts of their drivers with large addresses. The other relevant Boot.ini switch is /NOLOWMEM, which discards memory below 4 GB and relocates device drivers above this range, thus guaranteeing that these drivers will be presented with physical addresses greater than 32 bits.

Only Windows 2000 Advanced Server and Windows 2000 Datacenter Server are required to support more than 4 GB of physical memory. (See Table 2-2.) Using the AWE Win32 functions, 32bit user processes can allocate and control large amounts of physical memory on these systems.



Comments

Guest wrote I just don't understand
on 12-12-2004 1:19 PM
This message was originally posted by an anonymous visitor on March 4, 2004
One of our customers has a Terminal Server with 6Gb of RAM. It uses 32bit Win2k3 Enterprise with the /PAE witch enabled. So far, ive read thru different techdocs and made some conclusions. Please feel free to shoot at my conclusions as i dont know if they are right..

So here it comes;
Theres a true PAE and a x86 PAE. True is 64bits proccesors with 64bits windows, x86 PAE is an extension for 32bits procs and 32bits windows. All i've read is that x86 PAE lets u use more than 2Gb of ram for the kernel. I am not interested in the 2Gb limit apps like SQLServer or Exchange have, but in the kernel memory size so my users have more ram than the 2Gb appointed to the kernel. The appliance is Terminal Services here.
So why cant i use my extra 4G of memory? The server says it has 6Gb of ram but doesnt use it, coz theres 4Gb available while the server is swapping and very very busy.

Another question i have while trying to understand the problem is that ive read that the virtual memory appointed to a app is 4Gb on a 32bits Windows server system. Is this devided in 2G for the kernel and 2G for the app-pool? If so, is this why my Terminal Server users almost doesnt access the 4Gb? Coz the apps wont ever have use for more than 2G mem?

So my questions are;
-Why cant i use memory for my TS above 2Gb with the PAE switch enabled?

-is /PAE for the OS so that applications can use AWE to adress it?
-Do i have to do a reinstallation of Win2k3 ent to support the memory above 2Gb? or is adding the /PAE switch enough?

-How does Terminal Services uses memory? Why is it bound to the kernelmemory of 2Gb?
Guest wrote Answers to the previous poster's questions
on 12-12-2004 1:20 PM
This message was originally posted by Brian Madden on March 4, 2004
-Why cant i use memory for my TS above 2Gb with the PAE switch enabled?



The PAE switch does not give more memory to the kernel. It only gives more to the user-mode application processes. All PAE does is “trick” the application into thinking it has more space by creating multiple page tables for each application. In fact, using the PAE switch is bad in Terminal Server environments because each application will require 4 times as many page tables, which comes out of the limited 2GB space. If I were you, I would remove 2GB of memory so that you have only 4 total, and stop using the PAE switch.



-is /PAE for the OS so that applications can use AWE to adress it?



Yes


-Do i have to do a reinstallation of Win2k3 ent to support the memory above 2Gb? or is adding the /PAE switch enough?



You do not have to reinstall, just add the switch



-How does Terminal Services uses memory? Why is it bound to the kernelmemory of 2Gb?





In 32-bit Windows systems, the kernel can never ever use more than 2GB of memory. Period. Even with the x86 PAE, the kernel still is limited to 2GB. That’s just the way it is, and there’s no way around it.



The kernel is bound to 2GB because the memory manager can never address more than 4GB. Why? Because the memory manager uses 32-bit addresses for memory, and 2^32 = 4GB. This will probably never change, since 64-bit OSes are around the corner, and this 2GB kernel limit is only hit in Terminal Server environments. (usually)
Guest wrote Ok, what about 64bit then
on 12-12-2004 1:21 PM
This message was originally posted by Dave on March 19, 2004
So, the Mem mgr uses 32-bit addresses for memory in 32-bit Windows. What about on the currently available 64-bit version running on 64-bit hardware? 2^32=4GB cool, but 2^64=a very big number. Surely this implies that if I use a 64-bit version of the O/S and H/W I will have a VAST kernel memory space -and I don't think that is the case. What is the bit I am missing?
Guest wrote 64 bit Windows = HUGE kernel space
on 12-12-2004 1:21 PM
This message was originally posted by Brian Madden on March 19, 2004
This kernel memory limit only applies to 32-bit systems (from a practical standpoint). In 64-bit Windows, the whole VM is 16TB, as compared to 4GB for 32-bit (that's a factor of 4000x more space :-) The kernel space is somewhere around 2TB in 64-bit Windows, so it's something we probably won't have to worry about for 10 or 15 years.
Guest wrote clarifications
on 12-12-2004 1:21 PM
This message was originally posted by David Solomon on March 23, 2004
Brian - your statement "The kernel is bound to 2GB because the memory manager can never address more than 4GB. Why? Because the memory manager uses 32-bit addresses for memory, and 2^32 = 4GB." is incorrect. The memory manager on a system booted in PAE mode can address 64GB of RAM using 36-bit addressing. You are confusing virtual addressing with physical addressing. Also your statement "All PAE does is “trick” the application into thinking it has more space by creating multiple page tables for each application" is completely wrong. See my description of what PAE means on Windows in Inside Windows 2000, 3rd edition - Chapter 7.
Guest wrote Similar Problem on a Dual Processor system.
on 12-12-2004 1:21 PM
This message was originally posted by Ketul on March 26, 2004
We have the similar problem of application memory limit of 2GB. It's a dual processor server with Windows 2000 Server Standard Edition. Does this limit apply to each processor? or to a system as a whole? If we upgrade to Advanced Server and enable the PAE switch, will it allow to access more memory for the application? How does this play role in a dual processory environment? Does the memory management occurs similar to that of uniprocessor systems? In other words, how would you come over the 2GB limit on a multiprocessor system for application memory?
Guest wrote No Title
on 12-12-2004 1:21 PM
This message was originally posted by Arnold Bentley on March 30, 2004
Still Lost
Guest wrote Daul Processor Systems
on 12-12-2004 1:22 PM
This message was originally posted by Brian Madden on April 21, 2004
All of this stuff applies to systems as a whole. It doesn't matter if you have 1, 2, 4, 8, or more processors. The only way to "overcome" this memory limits (other than the PAE stuff discussed in the article) would be to move to a 64-bit Windows platform.
Guest wrote How about paging?
on 12-12-2004 1:22 PM
This message was originally posted by Bob on April 28, 2004
If the hardware system is only capable of adressing 4 Gb of memory, how much sense does it make to create a page file larger than 4 Gb?
It probably depends on your applications and the number of applications in use.
Guest wrote So what is the real world 32-bit memory limit?
on 12-12-2004 1:22 PM
This message was originally posted by James on May 7, 2004
After reading the above thread, David's comments ispute Brian's - my simple question is can 32-bit Windows Terminal Services ever use more than 2GB kernel memory in a "production" environment? And does this same limit apply to Citrix?
Cheers
Guest wrote The real 32-bit memory limit
on 12-12-2004 1:22 PM
This message was originally posted by Brian Madden on May 7, 2004
Oh yes, you can totally hit this limit. How you hit it varies on circumstances, but in Windows 2000, for example, you would hit this with about 200 or 250 TS users. You'd hit this limit even with 8 way processors with 8GB of RAM. And yes, this limit applies to Citrix as well, since this limit is an architectural limitation of 32-bit windows. Want to build a bigger box? 64-bit Windows on Opteron is your answer.
Guest wrote Additional Questions
on 12-12-2004 1:22 PM
This message was originally posted by Rick on May 7, 2004
I have two questions to ask regarding the processes running in the kernel address space and the number of user address spaces.

1) I have a server running Windows 2000 Advanced Server with 8gb memory. This is a database server that also runs some small health monitoring tools and cluster services. After rebooting the server and stopping the database engine, I can see from Task Manager that the operating system with its typical processes and the monitoring tools and cluster services all use a total of 1.1gb of memory. Task Manager shows kernel memory at around 200 - 300mb in the "Kernel Memory" box on the "Performance" tab. Are these other typical windows processes (about 20 of them) running in the kernel address space as well or the user address space ?

2) For this second question lets say I am still running Windows 2000 Advanced Server with 8gb memory. Lets also say I have installed a database program under one userid and an application program under a different userid. Lets also say that I have included the /PAE boot option in the boot.ini file. I am trying to understand if each userid has its own 2gb of user address space. Is it true that the database can use 2gb of user address space memory and the application can use 2gb of its own user address space memory (with the kernel using its own 2gb address space) ? This would mean my system could potentially use 6gb of the 8gb of available memory ? What happens if I don't use the /PAE boot option ?
Guest wrote Physical memory - Client Node
on 12-12-2004 1:22 PM
This message was originally posted by an anonymous visitor on May 26, 2004
"adding more than 4GB of physical memory to a server still doesn't change the fact that it's a 32-bit processor accessing a 32-bit memory space. Even when more than 4GB of memory is present"- You talk about server, how about client node, I did testing, I can use more than 3GB physical memory. If I have more than 4GB physical memory, I can create a test for using more than 4 GB physical memory.
Guest wrote Terminal Services on 64bit Windows Platform
on 12-12-2004 1:22 PM
This message was originally posted by Alan on June 2, 2004
If I were to implement the 64-bit Windows operating system would Terminal Services take advantage of this or is it a 32-bit application and still will not utilize the extra memory. Will any 32-bit applications gain the benefit of going to the 64-bit platform?
Guest wrote Ansys Distributed Domain Solver on windows 2003 enterprise edition-32 bit processor
on 12-12-2004 1:22 PM
This message was originally posted by Inayatullah Khan on June 3, 2004
I have used the pae and 3gb switch in the boot.ini plus the editbin utility to set the large address aware switch. The spawn process of the dds reaches the 3GB limit but abnormally terminated because it tries to utitlize memmory beyond 4GB.
Can you tell how can we check that an application has an AWE(address windowing extension) support
Guest wrote 48M Desktop Heap buffer - a restriction?
on 12-12-2004 1:22 PM
This message was originally posted by GC in SC on June 11, 2004
Every desktop object on the system has a desktop heap associated with it. The desktop object uses the heap to store menus, hooks, strings, and windows. The system allocates desktop heap from a system-wide 48-MB buffer. In addition to desktop heaps, printer, and font drivers also use this buffer. This is mentioned in KB 184802. What is this buffer and where is it? What if we want more heap room and want more the 48M? Is that feasible?
Guest wrote Free RAM but Page-ins and Page-outs
on 12-12-2004 1:22 PM
This message was originally posted by Christian on June 14, 2004
I am running an SAP-APO system on DB2 for Windows on Windows 2000 advanced server (The livecash part is on an other server). My server has 7GB RAM and the /PAE and /3GB switches are on. I'd like to understand why do I have hundreds of thousends of pages in and out even with 4 GB free RAM ?
Guest wrote So what is the final answer -- to /PAE or not to /PAE
on 12-12-2004 1:22 PM
This message was originally posted by an anonymous visitor on June 14, 2004
All of my Dell 2650's have dual Xeon, and 6 gig ram. The only apps are Office 2003. SHould I use the /3gb or /PAE
Guest wrote Even after I add the /PAE switch W$dows still displaying the wrong size of ram I have
on 12-12-2004 1:30 PM
This message was originally posted by an anonymous visitor on July 13, 2004
I have a C$mpaq 570 ML server with 4GB ram and W$dows 2000 Adv$nced Server running after awhile I add 4GB ram more and I did add the /PAE switch to Boot.ini file, after all W$dows still displaying the wrong size of ram I have which is 4GB only.
Thanks guys.
Guest wrote So, what do you do
on 12-12-2004 1:30 PM
This message was originally posted by bruce on July 22, 2004
if i'm understanding any of what is being said, it sounds like on a 32bit operating system, you should not expend the money to exceed 4gb of physical memory beyond 4gb. Would that be correct????