4GT RAM Tuning

For applications that are memory-intensive, such as database management systems (DBMS), the use of a larger virtual address space can provide considerable performance benefits. However, the file cache, paged pool, and non-paged pool are smaller, which can adversely affect applications with heavy networking or I/O. Therefore, you might want to test your application under load, and examine the performance counters to determine whether your application benefits from the larger address space.

On 32-bit editions of Windows, applications have 4 gigabyte (GB) of virtual address space available. The virtual address space is divided so that 2-GB is available to the application and the other 2-GB is available only to the system.

The 4GT RAM Tuning feature increases the memory that is available to the application up to 3-GB, and reduces the amount available to the system to between 1 and 2-GB, but the administrator can change this by using the /USERVA switch. This benefits applications that run on computers with more than 2-GB of physical memory, enabling them to keep more data in virtual memory without needing to swap it to disk.

To enable this feature, add the /3GB switch to the Boot.ini file. This enables applications to use the first 3-GB of the address space on the following systems:

  • Windows Vista
  • Windows Server 2003
  • Windows XP Professional
  • Windows 2000 Datacenter Server
  • Windows 2000 Advanced Server
  • Windows NT Server 4.0 Enterprise Edition

To enable an application to use the larger address space, set the IMAGE_FILE_LARGE_ADDRESS_AWARE flag in the image header. The linker included with Microsoft Visual C++ supports the /LARGEADDRESSAWARE switch to set this flag. Setting this flag, and then running the application on a system that does not have 4GT support should not affect the application.

On 64-bit editions of Windows, 32-bit applications marked with the IMAGE_FILE_LARGE_ADDRESS_AWARE flag have 4-GB of address space available.

Itanium editions of Windows Server 2003:  Prior to SP1, 32-bit processes only have 2-GB of address space available.
Itanium editions of Windows 2000:  32-bit processes only have 2-GB of address space available.

Use the following guidelines to enable 4GT support in applications:

  • For a DLL that loads near the 2-GB boundary, there is a region of the 2-GB space where contiguous memory cannot be allocated by using the VirtualAlloc function.
  • To retrieve the amount of total user virtual space, use the GlobalMemoryStatus function. Always detect the real value at runtime, and avoid using hard-wired constant definitions such as: #define HIGHEST_USER_ADDRESS 0xC0000000.
  • Avoid signed comparisons with pointers, because they might cause applications to crash on a 4GT-enabled system. A condition such as the following is false for a pointer that is above 2-GB: if (pointer > 40000000).
  • Code that uses the highest bit to tag items (that is, data value versus an address value) fail. For example, a 32-bit word might be considered a user-mode address if it is below 0x80000000, and an error code if above. This is not true with 4GT.

VirtualAlloc usually returns low addresses before high addresses. Therefore, your process may not use very high addresses unless it allocates a lot of memory or has a fragmented virtual address space. To force allocations to allocate from higher addresses before lower addresses for testing purposes, specify MEM_TOP_DOWN when calling VirtualAlloc or set the following registry value to 0x100000:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\
     Session Manager\Memory Management\AllocationPreference

See Also

Memory Limits for Windows Releases


Send comments about this topic to Microsoft

Build date: 6/1/2007

Community Additions

Show:
© 2014 Microsoft