<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Mfartura's blog : Memory Management</title><link>http://blogs.technet.com/marcelofartura/archive/tags/Memory+Management/default.aspx</link><description>Tags: Memory Management</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>/3GB, /PAE, AWE what??? (basic)</title><link>http://blogs.technet.com/marcelofartura/archive/2006/09/14/3gb-pae-awe-what-basic.aspx</link><pubDate>Thu, 14 Sep 2006 17:35:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:456214</guid><dc:creator>Marcelo Fartura</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.technet.com/marcelofartura/comments/456214.aspx</comments><wfw:commentRss>http://blogs.technet.com/marcelofartura/commentrss.aspx?PostID=456214</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;I've been following the discussions about these options for a long time. When it seems that everybody agrees on something, somebody else comes with a different understanding and the discussion starts all over again... The questions at the beginning of each thread about this subject are often the same: &lt;/FONT&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;When should I use /3GB option, and when should I not use it? &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Why should I have /PAE option in place? &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;What about /PAE and /3GB? Should they be used together? Or, can't they be used together? &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Are there any performance or reliability implications when using these options? &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Where AWE come from?&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;I understand you don't have to be an expert to perfectly understand these options and when they apply.&amp;nbsp; Let's try applying the KIS (Keep&amp;nbsp;It Simple)&amp;nbsp;technique here, and see how all these options work in a very basic, or simple, way.&amp;nbsp; But first let's make sure some basic concepts, very important to understand&amp;nbsp;those options, are covered: &lt;/FONT&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT face=Verdana size=2&gt;A very simple vision of Processes, Applications and Virtual Memory&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;B&gt;&lt;BR&gt;&lt;/B&gt;&lt;FONT face=Verdana size=2&gt;Imagine a classroom with any number of students. This classroom have a set of minimum resources like chairs, desks and notebooks for the students, a whiteboard etc. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The &lt;STRONG&gt;Processes&lt;/STRONG&gt; are what is represented by the classroom to the students in this example, or a space shared by them and their resources. The space occupied by the&amp;nbsp;students and the resources&amp;nbsp;within the classroom is limited, as it is the Virtual Address Space of a Process, or it's &lt;STRONG&gt;Virtual Memory&lt;/STRONG&gt;. While we measure the space limit of a real classroom in square feet, we do for a process and its virtual address in GBytes with the difference that classrooms can be any size and a process virtual address space is always 4GBytes large when working with 32 bit architecture - 2^32 = 4G. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The &lt;STRONG&gt;Applications&lt;/STRONG&gt; will be the students in the classroom. You can have multiple students sharing the same classroom, so you can have multiple Applications hosted by the same process, or in other words, sharing the same virtual address space. Actually, for instance when a process is created to host a Win32 app, it will also host at least the application responsible for providing the interface to the executive (ntdll.dll) and one of the applications which provide the Win32 APIs (kernel32.dll).&amp;nbsp; So, when we start up a very simple application, its process will also host at least 2 additional other applications. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The Virtual Address Space of each process is divided in two regions: The User Mode where the mentioned applications will run and the Kernel Mode which will be a representation of an address space that is exclusively accessed by the OS kernel. By default the distribution is 50/50 or 2GBytes being available to all User Mode apps sharing the same address space, or being hosted by the same process, and 2GBytes for the kernel. Back to our example, suppose our classroom has its available space reduced to half of the total size. The students can not access the other half. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;&lt;STRONG&gt;&lt;U&gt;Now, direct to the point:&lt;/U&gt;&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/FONT&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;&lt;STRONG&gt;/3GB&lt;/STRONG&gt;&lt;BR&gt;The /3GB boot.ini option or &lt;/FONT&gt;&lt;/FONT&gt;&lt;A href="http://windowssdk.msdn.microsoft.com/en-us/library/ms693497.aspx" mce_href="http://windowssdk.msdn.microsoft.com/en-us/library/ms693497.aspx"&gt;&lt;FONT face=Verdana color=#669966 size=2&gt;4GT Ram tuning&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; as it's called, will change the way the virtual address space is divided between the kernel and the user mode application on each process. As said before, by default, when not using /3GB option, the division is 50/50. When using the /3GB though, the division becomes 25/75 so the Kernel will reduce its virtual address space to 1GB and the address space used by User Mode apps will earn the additional 1GB so becoming 3GB. Let's take a look at the picture below for a better illustration on what happens when we're not using the /3GB option:&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/photos/mfartura/picture456339.aspx" target=_blank mce_href="http://blogs.technet.com/photos/mfartura/picture456339.aspx"&gt;&lt;IMG src="http://blogs.technet.com/photos/mfartura/images/456339/471x480.aspx" border=0 mce_src="http://blogs.technet.com/photos/mfartura/images/456339/471x480.aspx"&gt;&lt;/A&gt;&lt;A href="http://blogs.technet.com/photos/mfartura/picture456339.aspx" target=_blank mce_href="http://blogs.technet.com/photos/mfartura/picture456339.aspx"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The 4 billion 32 bit addresses in hex format will go from 0x00000000 to 0xFFFFFFFF. When not using the /3GB option, the line which separates the Kernel and User Mode addresses is placed in the middle, at the address 0x7FFFFFFF in a way that the User Mode addresses are from 0x00000000 to 0x7FFFFFFF and the Kernel Mode addresses start at 0x80000000. Now, let’s look on what happens when we do have the /3GB option in place: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/photos/mfartura/picture456338.aspx" target=_blank mce_href="http://blogs.technet.com/photos/mfartura/picture456338.aspx"&gt;&lt;IMG src="http://blogs.technet.com/photos/mfartura/images/456338/474x480.aspx" border=0 mce_src="http://blogs.technet.com/photos/mfartura/images/456338/474x480.aspx"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;As we can see the line was lowered and the addresses scheme for both User and Kernel Mode changed. Now, the addresses used by User Mode apps are from &lt;STRONG&gt;0x0000000 to 0xBFFFFFFFF&lt;/STRONG&gt; and the ones used by the Kernel are from &lt;STRONG&gt;0xC0000000 to 0xFFFFFFFF&lt;/STRONG&gt;. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;However the fact that the address space accessible by the User Mode applications is now larger might not represent any advantage to the applications. The applications will need to be aware of this larger address space. They need to be designed to make use that. The applications need to be compiled with a special link option called &lt;/FONT&gt;&lt;A href="http://windowssdk.msdn.microsoft.com/en-us/library/ms680349.aspx" mce_href="http://windowssdk.msdn.microsoft.com/en-us/library/ms680349.aspx"&gt;&lt;FONT face=Verdana color=#669966 size=2&gt;IMAGE_FILE_LARGE_ADDRESS_AWARE&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; otherwise they won't use the additional 1GB of virtual memory.&amp;nbsp;&amp;nbsp; The tool dumpbin.exe from the Visual Studio can tell, when using the flag /HEADERS (&lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcreflargeaddressaware.asp" mce_href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcreflargeaddressaware.asp"&gt;&lt;FONT face=Verdana color=#669966 size=2&gt;dumpbin.exe /HEADERS&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;),&amp;nbsp;if the application has this link option enabled or not. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;In the other side, the 1GB the Kernel needed to give up from, might be missed because the memory reduction affects key memory areas like, for instance, the file system cache (it directly impacts the paged and non-paged pool sizes and drastically reduces the number of system PTEs - but this is outside the scope of this article) and this may impact the reliability and performance of the entire system. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The conclusion is that the only general recommendation for the usage of /3GB option is do not use it unless it's required by the vendor of the application the sever is dedicated to. There are, for instance, specific recommendations for Domain Controllers, SQL Servers, Exchange Server etc, but no general rule for using it.&amp;nbsp; Also, make sure the rules of your server do not conflict regarding the /3GB recommendation.&amp;nbsp; For instance, if you have a SQL Server and File Server running in the same box, you will need to deal with the conflict that for a SQL Server the use of /3GB is recommended however for a File Server it is recommended to do not use it. &lt;/FONT&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;/PAE&lt;/FONT&gt;&lt;/STRONG&gt;&lt;B&gt;&lt;BR&gt;&lt;/B&gt;&lt;FONT face=Verdana size=2&gt;Now that we know&amp;nbsp;where the 4GBytes limit comes from (32-bit procs -&amp;gt; 2^32 = 4G) we also understand that the OS kernel itself&amp;nbsp;will not be able to see beyond that either.&amp;nbsp; Something needed to change&amp;nbsp;at the processors in&amp;nbsp;order to be able to address beyond the 4GBytes. &amp;nbsp;The &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/whdc/system/platform/server/PAE/PAEdrv.mspx" mce_href="http://www.microsoft.com/whdc/system/platform/server/PAE/PAEdrv.mspx"&gt;&lt;FONT face=Verdana color=#669966 size=2&gt;Physical Address Extension (PAE)&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; is an extension provided by intel (the 6th feature, or the bit 6 = 1 in the feature flags of the processor) to enable 32-bit processors to support more than 4GBytes of RAM.&amp;nbsp; Looking at that in&amp;nbsp;a very simple way, it makes the processors be able to address up to 64GBytes through providing a &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/whdc/system/platform/server/PAE/pae_os.mspx" mce_href="http://www.microsoft.com/whdc/system/platform/server/PAE/pae_os.mspx"&gt;&lt;FONT face=Verdana color=#669966 size=2&gt;36-bit physical addressing mode&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;.&amp;nbsp; So, with 36 bits available for physical addressing, the process is able to use 2^36, or 64 billion addresses, instead of the original 4 billion.&amp;nbsp; &lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The OS kernel also needs to be aware of this since it will need to change its address translation scheme (PAE Kernel will introduce a third level - PDPE - in the address translation) to proper handle the memory beyond the 4GB.&amp;nbsp; The /PAE option at the boot.ini will make the PAE kernel (ntkrnlpa.exe for single proc machines or ntkrnlpamp.exe for multiproc machines&amp;nbsp;- SMP) to be loaded, instead of the regular one (ntoskrnl.exe).&amp;nbsp; &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Notice that PAE has no effect at the processes Virtual Address Space as they are still 4GB large regardless of the amount of physical memory in the system.&amp;nbsp; So referencing back our classroom example, we could say that there are several classrooms (or processes)&amp;nbsp;in our building (or running in the OS) and that the PAE will provide more space to the building &lt;/FONT&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;AWE&lt;/FONT&gt;&lt;/STRONG&gt;&lt;B&gt;&lt;BR&gt;&lt;/B&gt;&lt;FONT face=Verdana size=2&gt;We know that&amp;nbsp;PAE will&amp;nbsp;make&amp;nbsp;the processor&amp;nbsp;be able to address 36 bits and&amp;nbsp;the OS, if&amp;nbsp;the correct kernel gets loaded (through the /PAE option), will be able to see beyond&amp;nbsp;4GB of&amp;nbsp;physical memory.&amp;nbsp; However we did not mention anything&amp;nbsp;about how&amp;nbsp;this will impact the application behaviors.&amp;nbsp;&amp;nbsp;The&amp;nbsp;application are, by default, still on that same classroom with 2GB (or 3GB if&amp;nbsp;4GT is enabled) even with the PAE enabled.&amp;nbsp; The &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/address_windowing_extensions.asp" mce_href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/address_windowing_extensions.asp"&gt;&lt;FONT face=Verdana color=#669966 size=2&gt;Address Windowing Extension (AWE)&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;is a set of&amp;nbsp;extension APIs&amp;nbsp;that the application need to use in order to make use of the same 32-bit large pointers to access physical memory beyond 4GB.&amp;nbsp; In other words, if the application was not developed to take benefit of that, even on systems with way more memory than 4GB they will still be limited to&amp;nbsp;2GB (or&amp;nbsp;3GB if 4GT is enabled).&amp;nbsp; The SQL Server is as example of application that uses AWE.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt;&lt;STRONG&gt;&lt;U&gt;Putting all together:&lt;/U&gt;&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The &lt;STRONG&gt;/3GB&lt;/STRONG&gt; option is to be used whenever, and only, the application vendor requires or recommends it.&amp;nbsp;&amp;nbsp; The applications&amp;nbsp;must to be compiled with the &lt;/FONT&gt;&lt;A href="http://windowssdk.msdn.microsoft.com/en-us/library/ms680349.aspx" mce_href="http://windowssdk.msdn.microsoft.com/en-us/library/ms680349.aspx"&gt;&lt;FONT face=Verdana color=#669966 size=2&gt;IMAGE_FILE_LARGE_ADDRESS_AWARE&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; in order to take advantage of it and it&amp;nbsp;has no necessary relationship with the amount of&amp;nbsp;physical memory the&amp;nbsp;system&amp;nbsp;has available.&amp;nbsp; However if the system has more than 4GB of physical RAM and it's not 64-bit, you will need to use the &lt;STRONG&gt;/PAE&lt;/STRONG&gt; option to make the OS aware and use beyond the 4GB limit. &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;If you have the /PAE and /3GB used together, the system will limit the physical memory usage to 16GB regardless of the amount of memory beyond that (this is due to the exhaustion of kernel resources to do both addressing large amounts of memory and reduce it's virtual space to 1GB, but this is subject to another article :-)). &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;If you have more than 4GB of physical RAM, be aware that just enabling PAE will not make the applications to actually make usage of any additional memory unless they are properly designed for that (they must use the &lt;STRONG&gt;AWE&lt;/STRONG&gt; special APIs for this). &lt;/FONT&gt;&lt;/P&gt;&lt;A href="http://blogs.technet.com/photos/mfartura/picture456339.aspx" target=_blank mce_href="http://blogs.technet.com/photos/mfartura/picture456339.aspx"&gt;&lt;/A&gt;&lt;A href="http://blogs.technet.com/photos/mfartura/picture456338.aspx" target=_blank mce_href="http://blogs.technet.com/photos/mfartura/picture456338.aspx"&gt;&lt;/A&gt;&lt;A href="http://blogs.technet.com/photos/mfartura/picture456338.aspx" target=_blank mce_href="http://blogs.technet.com/photos/mfartura/picture456338.aspx"&gt;&lt;/A&gt;&lt;A href="http://blogs.technet.com/photos/mfartura/picture456339.aspx" target=_blank mce_href="http://blogs.technet.com/photos/mfartura/picture456339.aspx"&gt;&lt;/A&gt;&lt;A href="http://blogs.technet.com/photos/mfartura/picture456339.aspx" target=_blank mce_href="http://blogs.technet.com/photos/mfartura/picture456339.aspx"&gt;&lt;/A&gt;&lt;A href="http://blogs.technet.com/photos/mfartura/picture456338.aspx" target=_blank mce_href="http://blogs.technet.com/photos/mfartura/picture456338.aspx"&gt;&lt;/A&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=456214" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/marcelofartura/archive/tags/Basic/default.aspx">Basic</category><category domain="http://blogs.technet.com/marcelofartura/archive/tags/PAE/default.aspx">PAE</category><category domain="http://blogs.technet.com/marcelofartura/archive/tags/4GT/default.aspx">4GT</category><category domain="http://blogs.technet.com/marcelofartura/archive/tags/Boot.ini/default.aspx">Boot.ini</category><category domain="http://blogs.technet.com/marcelofartura/archive/tags/Memory+Management/default.aspx">Memory Management</category><category domain="http://blogs.technet.com/marcelofartura/archive/tags/3GB/default.aspx">3GB</category></item></channel></rss>