Microsoft KB Archive/171793

From BetaArchive Wiki

Article ID: 171793

Article Last Modified on 10/31/2006



APPLIES TO

  • Microsoft Windows NT Server 4.0 Enterprise Edition



This article was previously published under Q171793

SUMMARY

This article describes the 4GT RAM Tuning feature of Windows NT Server Enterprise Edition (Windows NT Server/E) version 4.0. With standard Windows NT Server, the per-process address limit is 2 gigabytes (GB) of random access memory (RAM). The 4GT feature of Windows NT Server/E increases this limit to 3 GB without introducing new APIs. 4GT does this by reducing the potential RAM allocated to the Windows NT kernel from 2 GB to 1 GB.

Much of the information in this article was extracted from the Release Notes for the product.

MORE INFORMATION

Applications developed for the Windows NT Server platform continue to grow, both in terms of size and performance demands. For applications that are I/O intensive, such as database management systems (DBMS), the use of a larger process space can provide considerable performance benefits as time- intensive I/O access to media is reduced. With the current Windows NT Server product, the per-process address limit is 2 GB. 4GT increases this limit to 3 GB without introducing new APIs. 4GT does this by reducing the potential RAM allocated to the Windows NT kernel from 2 GB to 1 GB.

This feature benefits applications that run on powerful computers with more than 2 GB of physical RAM and that can take advantage of a larger address space. The impact on developers and applications are summarized below.

Windows NT Server/E supports 4GT on Intel architecture servers only.

NOTE: The 4GT works only on 32-bit processors, so it does not increase the addressable memory of Windows NT Server beyond its current limit of 4 GB.

Writing Applications for 4GT

User-mode Address Selection:

When 4GT is enabled, the highest bit of a virtual address cannot be used to differentiate user-mode addresses from kernel-mode addresses.

Memory Allocation Issues:

Some dynamic link library (DLL) files load near the 2 GB boundary; therefore, there is a region of the 2 GB space in which contiguous memory cannot be allocated using VirtualAlloc.

Effects Visible in Kernel Mode:

Kernel-mode code can no longer assume the user/kernel boundary is at 0x80000000 or at any other number. Code that uses ProbeForRead or ProbeForWrite macros must be rebuilt using new headers that no longer contain assumptions about kernel space starting at 0x80000000.

Enabling 4GT Support in Your Applications

The changes to support 4GT are done at both the system and application levels.

System Changes:

After you have installed Windows NT Server/E, you must modify the Boot.ini file to enable 4GT. To enable 4GT, simply add the /3GB parameter to the startup line.

NOTE: This change is only effective if you are using Windows NT Server/E. On standard Windows NT, this flag will relocate the kernel, but applications will be unable to access more than 2 GB.

For example:

[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="Windows NT Server Version 4.00" /3GB
multi(0)disk(0)rdisk(0)partition(2)\WINNT="Windows NT Server Version 4.00 [VGA mode]" /basevideo /sos


NOTE: Some of the lines above have been wrapped for readability.

Application Changes:

No new APIs are required for 4GT support. Instead, memory allocations remain the same, with the exceptions that are noted below in "Tips for Effective 4GT Support." However, it would be ineffective for every application to automatically be provided with a 3-GB address space. To provide a selective use of 4GT, the following mechanism has been implemented:

  • Executables that must see the 3-GB address space are required to have the bit IMAGE_FILE_LARGE_ADDRESS_AWARE set in their image header. This can be done using the Imagecfg tool that is included in the Support folder on the Windows NT Server/E compact disc. For example, to modify the target file DBMSApp.exe, type the following at a command prompt:

    Imagecfg -l DBMSApp.exe

NOTE: The linker also has a new switch (/ LARGEADDRESSAWARE) to link executables with the IMAGE_FILE_LARGE_ADDRESS_AWARE bit. Setting this bit and then running the application on a system that does not have 4GT support should not affect the application.

Tips for Effective 4GT Support

The following guidelines are intended as a summary of changes that developers will want to review when they consider enabling 4GT support within their applications:

  • Use GlobalMemoryStatus to get the amount of total user virtual space. Avoid using hard-wired constant definitions such as "#define HIGHEST_USER_ADDRESS 0xC0000000". Try to detect the real value at runtime.


  • Avoid signed comparisons with pointers. Some applications might crash on a 4GT-enabled system for just this reason. A condition such as "if (pointer > 40000000)" will be false for a pointer that is above 2 GB.


  • Code using the highest bit to tag items (data value versus an address value) will fail. For example, a 32-bit word might be considered a user- mode address if below 0x80000000 and an error code if above. This does not work anymore.

Setting a Paging File Size

If you are using the 4GT option and have a system with greater than 3 GB of physical memory, you may want to consider changing the default size of your page file. Note that this is changed by using the System tool in Control Panel. In Windows NT 3.51, the default pagefile size is generally 11 MB larger than physical memory. In Windows NT 4.0, the default pagefile size is equal to the amount of physical memory on the system. On a 4-GB computer, this would result in a 4.01-GB paging file. Under such circumstances, the effectiveness of this paging file could be minimal, based on the total size, which is 4 GB. Accordingly, a 256-MB page file could be a more effective use of disk space. However, having a smaller paging size will affect the total memory commit size for applications. You should review these settings with the Independent Software Vendor (ISV) for your applications that are being run with the 4GT option.

Keywords: kbhowto kbinfo KB171793