Author: eaglet
In 2008, I wrote a blog called "Let. net Applications break through 2 GB memory access limit. This blog mainly describes how to use AWE extension to access more than 2 GB memory in a 32-bit operating system. Although AWE can access more than 2 GB of memory, it also has some problems. First, you must lock the memory, and then write your own memory management program to manage the memory ,.. net framework cannot create a managed heap in the extended AWE memory. In fact, many applications only want to apply for more memory than 2 GB. The simplest method is to use the/3 GB switch. This article describes how to use the/3 GB switch to allow 32-bit. net Applications to apply for memory exceeding 2 GB.
First, let's talk about this/3 GB switch (you can skip it if you know it)
By default, Windows can address a virtual address space of 4 GB in total. By default, 2 GB in this address space is reserved for the kernel (operating system), and 2 GB is reserved for the user mode program. When you put the/3 GB switch into the operating system Boot. in the ini file, you are allocated a new virtual address space, providing 3 GB space for user mode programs, and limiting the kernel to 1 GB.
Configuration method: Modify the C: \ boot. ini file as follows:
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(2)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINNT="????" /3GB
The following operating system supports/3 GB Switch
Windows XP Professional
Windows Server 2003
Windows Server 2003, Enterprise Edition
Windows Server 2003, Datacenter Edition
Windows 2000 Advanced Server
Windows 2000 Datacenter Server
Windows NT Server 4.0, Enterprise Edition
Windows VISTA, Windows 7, and Windows server 2008 also support this switch.
For details, see
Http://www.microsoft.com/whdc/system/platform/server/PAE/PAEmem.mspx
After the settings are complete, restart the system. Then, the application can apply for memory exceeding 3 GB. It seems that this is the end, but this is not the case.
When I run. net framework test program, I found that after the 3 GB switch is turned on, this test program still cannot apply for more than 2 GB memory, the memory can not be allocated when applied to more than GB memory.
After searching for the information, I found that the application had to make corresponding changes after the operating system supported the/3 GB parameter, and told the operating system to run in the/3 GB mode, I think this is probably due to considerations for application compatibility.
To inform the operating system that this application supports the/3 GB mode, we need to addIMAGE_FILE_LARGE_ADDRESS_AWARE
Flag. The method to add is simple:
In the system's Program Files \ Microsoft Visual Studio 8 \ VC \ bin directory, findeditbin
The executable file is executed in the command line:
editbin
/In LARGEADDRESSAWARE yourapplication.exe, yourapplication.exe must enter the path name and file name of Your. net application.
After this statement is executed, I run the test program again, and the memory can be applied for up to GB. I can use 1 GB memory more than 2 GB memory.
In the end, why can only a. net application request a maximum of 1.4-1.6 GB memory in 2 GB?
This is because the. net Garbage Collector needs to copy live objects during work, And the. net framework needs to reserve a certain amount of memory for it to complete the copy. This is also why Microsoft recommends that the maximum memory allocation of asp.net applications be set to MB.
For details about how to optimize the performance of. net applications, refer to the following link. If you are interested, you can check it out. I will not talk about it more here, but it is a little far away from the topic.
Improving. NET Application Performance and Scalability