3GB Switch

From DpWiki

(Redirected from 3GB)
Jump to: navigation, search

Warning

This article covers an advanced topic and improper usage of these settings may cause adverse effects. Please carefully read the entire contents of this article before implementing any changes.

Contents

Introduction

In their default configuration, 32-bit versions of Windows limit individual programs to using no more than 2GB of virtual memory at any given time. As many photographers are now buying computers with upwards of 4GB of memory, this limitation can prevent their systems from taking full advantage of that additional RAM. To combat this problem, several of Microsoft's newer Operating Systems (including Windows XP Professional) provide this switch to expand the ammount of memory available to each program.

Warning: The /3GB switch is an advanced feature of these Operating Systems and is not intended to be used lightly. It carries with it a number of significant caveats, and the user should be extremely careful when playing around with this switch.

How it Works

To understand how the /3GB switch works, one has to understand the difference between virtual and physical memory. Programs running on Windows (and pretty much all modern OSes) work within their own block of virtual memory space. That is, each program has its own isolated set of virtual memory addresses to work within - when that program attempts to access data at a specific address, the OS and processor dynamically translate those virtual addresses into physical ones. This abstraction of memory access provides a number of advantages over direct access, however they are beyond the scope of this document. Please see the virtual memory article for more information on this topic.

This set of virtual addresses consists of the integers 0 to 4,294,967,295 - if each of those addresses are mapped to a single byte of memory, the program would be able to access up to 4GB of virtual memory. Unfortunately, there are other things that these addresses must be used for (such as communication with the underlying OS and hardware), so there are additional constraints in force.

In order to facilitate these functions, a portion of these virtual addresses are designated as 'kernel space' and shared between all programs running on the system. Those programs can access the resources mapped into these addresses in order to communicate with the rest of the system. The details of how this memory is actually used is beyond the scope of this document, however it is not required to understand the basic operation of this switch.

In its default configuration, Windows divides the range of virtual addresses in half and provides the lower 2GB portion (0-2,147,483,647) for the use of the program, and the upper half (2,147,483,648-4,294,967,295) to act as the shared kernel space (mentioned above). This is where the /3GB switch comes into play - it shrinks the set of addresses assigned for kernel use down to 1GB so that 3GB of space is left for the program itself. As such, each program running on the system potentially has more room to store data.

Potential Issues

The problem with this, however, is that few people know about this feature and only a fraction of those users actually make use of it. As such, many developers of device drivers simply assume that they have the standard 2GB block of kernel address space to work with and hard code their drivers along those lines (which is admittedly true for 99.999% of installations). If you shrink that space down, any drivers making this assumption are going to experience problems. At the very least it will generally lead to a very unstable machine, at the worst it will prevent the machine from booting at all.

The most common culpret for this type of problem is the video card. Modern graphics cards often have large quantities of onboard memory that must be mapped into the virtual address space. This process requires a sizeable contiguous block of addresses within the kernel space, so the 1GB limit can become a serious liability. If there is insufficient space, the driver will often fail to load and cause the system to crash durring the boot up phase.

Fine Tuning - the /USERVA Switch

The /USERVA Switch can help to remedy this problem, as it allows users to fine-tune the assignment of memory. When combined with the /3GB Switch, this allows the memory allocated for programs to be set to any value between 2GB and 3GB. In many cases, a threshold can be found that prevents driver problems while still providing software with additional working space. Finding the appropriate value can, however, take some work.

Limitations

It is important to note that software must be specially written to take advantage of this feature. Software which is not explicitly marked for this mode will still be limited to the conventional 2GB boundary and will not see any benefits from it being enabled. As such, users should be aware that the benefits of this switch are limited.

While most software does not support this feature, the one notable exception is Adobe's Photoshop CS2. When the /3GB switch is enabled, this version of Photoshop will take full advantage of the additional memory space and can see improvements in performance when working with large files. It is for this reason that many photographers have elected to take advantage of this switch.

Compatibility

Other Issues

As noted above, the ability for a system to function in this mode is critically dependant on the drivers and hardware in use. As all it takes to cause problems is a single device driver or piece of hardware, there is no way to be 100% certain that the switch will work. As such, the user must either find an identical configuration that has been explicitly tested with it or set things up and test it out first hand.

Due to these issues, it is generally recommended that users buying new computers focus their energy on seeking compatibility with 64-bit OSes. While this switch will work on many systems, there is no absolute guarantee that it will function.

Testing

It should be noted that many of the adverse effects caused by this switch will be triggered regardless of how much physical memory is in the system. As such, for users considering the addition of more memory to their systems it is possible to test this switch out before performing the upgrade. While it won't provide any performance benefits until the new RAM is added, it will help to determine if there are any potential issues with the switch.

Using the Switch

Boot.ini

The /3GB switch and /USERVA Switch are controlled by editing a small text file called boot.ini. This file is loaded by low-level portions of the OS before the central portions of Windows actually start, so it allows the user to fine tune a number of parameters. As such, users should take extreme care when making changes to this file.

Activating /3GB

Warning: - As mentioned above, please note that activating this switch may prevent the machine from booting properly. As such, make sure that you read through this entire document before following these steps. It is strongly recommended that you write down the instructions in the following section for recovering from a failed boot.

  1. Go to the Start menu and navigate to Programs->Accessories->Notepad.
  2. When Notepad is loaded, go to File->Open and load the file C:\boot.ini (it will likely be hidden so type it into the File name box and hit enter).
  3. Before editing any further, resave the file to C:\boot.bak.txt so you've got a working backup of your settings.
  4. When the file is loaded, you should see a line such as the following:
    multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
  5. Add a space character and then /3GB to the end of the line. Unless you know exactly what you are doing, it is strongly advised that you take care not to modify anything else within this file.
  6. Go to the File menu and select 'Save As...'. Enter "C:\boot.ini" (note that the quotation marks are important, as Notepad will append .txt if they are not present).
  7. Close Notepad and shut down the computer. Restart it and Windows will attempt to boot with the /3GB setting activated.

In Case of Trouble

If the computer fails to boot after making this change, you likely have a driver that will not function in the standard /3GB mode, so you will either have to disable the switch or fine tune the setting. To reverse the change, you will first need to restart the machine in Safe mode. To do this, perform the following steps:

  1. As the computer restarts, but before Windows launches press the F8 key to get the boot menu (Windows may do this automatically for you).
  2. Highlight the 'Safe Mode' entry with the up and down arrows and press enter to begin booting.
  3. Windows will now boot into safe mode, with the /3GB switch temporarilly disabled.
  4. Open Notepad (Start->Programs->Accessories->Notepad) and open the C:\boot.bak.txt file that you created above. If you didn't do this, simply delete the /3GB switch that you added earlier.
  5. Go to File->Save As... and resave the file as "C:\boot.ini" (again, note that the quotation marks are important).
  6. Reboot the machine and it should return to the way it was working before this change.

If you would like to fine-tune the settings, see the article covering the /USERVA Switch for more details. This switch allows you to adjust the exact ammount of memory allocated to the user mode, so it can often overcome problems that the standard /3GB configuration runs into. There is no guarantee that this will resolve the problem, however, so you may need to return to the standard configuration.

Instability

Note that even if the machine is able to boot with this switch enabled, it can still potentially cause stability issues with the machine. After making this change, users should carefully monitor the stability of the machine to ensure that it has not been adversely effected. While this setting typically causes very obvious symptoms when there is an issue, it does periodically trigger more subtle signs.

Common Misconceptions

As the underlying manner in which this switch operates is rather complex, there are a number of misconceptions that many users have with its operation. A few of the more common ones are listed in the following sections:

Without the /3GB switch, the system will only use 2GB of memory

The /3GB switch controls the virtual memory space allocated to each program. It does not have any effect on the way that the physical memory within the system is handled. That is, this switch controls the ammount of memory that individual programs can make use of, not the ammount of memory that the system can use.

For instance, take the example of a computer with 4GB of RAM installed and the /3GB switch disabled. If you ran a single memory intensive program, it would indeed be limited to using only 2GB of that RAM. If, however, a second program was launched on that machine it could use up to 2GB of its own memory. While each piece of software is limited to 2GB, the two programs combined can make use of all of the memory available to the machine.

Alternatives: Windows XP x64 Edition

One way to work around the limitations listed above is to use a 64-bit computer and install Windows XP x64 edition. As kernel-mode components of the OS had to be rewritten for this OS, they are designed to work within a much larger memory space. As such, the functionality provided by the /3GB switch is automatically available to any 32-bit software that requests it (such as Photoshop CS2). As this does not require any manual intervention, the user does not need to concern themselves with these details so the use of large banks of memory is much simpler.

It is important to note that existing 32-bit drivers will not work on this OS. As such, users should be careful to ensure that drivers are available for all of the devices they would like to use with the machine. While this is much less of a problem than it was a few months ago, there are still a few devices that aren't supported by Windows XP x64 edition.

See Also

  • Virtual Memory - The mechanism that is used by modern systems to dynamically manage memory. This switch controls several facets in the operation of this system.
  • /USERVA Switch - Another switch that provides the user with the ability to fine tune this setting.

External Links

Personal tools