You may receive the "System.OutOfMemoryException" error message when you view ASP.NET pages on a server that has 3 gigabytes of RAM


When you view ASP.NET pages on a server that has 3 gigabytes (GB) or more of RAM installed, you may receive the following exception error message, regardless of whether there is still physical memory available on the server:


The common language runtime throws an OutOfMemoryException error if it cannot allocate physical memory—or reserve sufficient virtual memory (VM)—to fulfill allocation request. By default, the addressable virtual memory space that is available for the process is 2 GB. If the virtual address space is exhausted, the operating system cannot allocate more physical memory for the process.


On computers running the following operating systems, you can turn on the special feature 4GT RAM Tuning:
  • Microsoft Windows Server 2003 family
  • Microsoft Windows XP Professional Edition
  • Microsoft Windows 2000 Datacenter Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows NT 4.0 Enterprise Edition
The 4GT RAM Tuning feature permits each process to address up to 3 GB of virtual memory. To turn on this feature, add the /3GB switch to the Boot.ini file.

For more information, visit the following Microsoft Web site:
Because of operating system limitations, single-process configurations cannot address more than 3 GB of virtual memory. To use the available physical memory more efficiently, use multiple processes. For example, ASP.NET under Microsoft Internet Information Services (IIS) 5.0 permits Webgarden mode to run one worker process for each CPU on a multiple-CPU server. For systems running IIS 6.0, you can configure your Web site to run separate applications in an application pool.

However, even with the 4GT RAM Tuning feature turned on, a single process cannot allocate all 3 GB of memory. All system DLLs are loaded in fixed VM addresses. Therefore, the upper VM area becomes fragmented. The memory manager must reserve a segment of VM to make the memory allocation. The process cannot allocate more memory if the memory manager cannot find a contiguous VM address range for the next segment. Typically, the segment size is sufficiently large (32 or 64 MB).

This problem is not specific to ASP.NET or the common language runtime. It is an operating system restriction for any type of process.


This behavior is by design.


For more information about 4GT RAM Tuning, visit the following Microsoft Web site: For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
171793 Information on Application Use of 4GT RAM Tuning
316739 How to Use the /USERVA Switch in the Boot.ini File to Tune /3GB Configurations