Have you ever had a problem in Windows XP where you can't open any more programs, but not because you don't have enough available system memory?
I'm talking about the situation where you cannot even right-click on a program in the taskbar and get the system menu to come up. The CPU utilization is fine, there is plenty of RAM available, but nothing works not even clicking on a notepad shortcut. It's dang frustrating!
The only thing that seems to work is to close opened programs. Once you do this, suddenly things start to work again.
You may be saying to yourself, "What the heck is this guy talking about?!". Well, I'll explain. As a software developer, I find I have the need to open many programs at once. Anything from several instances of Visual Studio (2003 & 2005) to browser windows to explorer windows to management windows, etc. And once you get to a certain number of programs, the operating system will stop functioning.
I'd better explain a few concepts before I get too deep into the discussion.
Everytime you open a program, every visual item on the screen is known to the OS (operating system) as a "window". Take for example the very program that you are using to view this blog (if you are using a Microsoft OS) whether that is Firefox, IE, Opera etc. etc. In the active window there are actually about 15 OS "windows" (in IE 6) that are being rendered to create the cohesive interface that you are using.
Here are some image examples:

and
and
and
These are all examples of what your operating system considers a "window".
Each window is allocated memory, so the more complex your application (Visual Studio or Outlook) the more memory is required for all these individual "windows" that comprise the interface you are using.
So your system has one or two Gigabytes of RAM and you're sitting there thinking, "No way this would happen to me!" Well, you would be mistaken.
See each "window", icon and string are allocated memory from a very specific location. This location is known as the "desktop heap". This special memory location is set to a specific size by the operating system and as soon as you run out of it, bam! you are toast.
(If you want to deliberately experience this specific type of Out-of-Memory condition, you can reproduce it by doing the following: create a shortcut to Notepad.exe or Calc.exe on your quicklaunch bar, click on this shortcut repeatedly until you can't launch another window. You may have to launch as many as 100-200 instances depending on how your system is configured. If you are thinking that I must be crazy to run so many windows and of course it won't work, I'll explain that later.)
In XP there is the concept of a desktop. "So what", you say, "I know that." But what you may not know is that there are different desktop areas, three (3) to be precise. Global, Interactive and Non-interactive. The first is a place where shared system settings and other system memory values are stored. The second is the desktop area with which you are probably most familiar. It is where all visible programs are displayed. The third is where all non-visible programs such as Windows services are run.
Additionally there are by default three "desktops" in the Interactive area, the Winlogon, the Default and the Screensaver. Each one of these desktops are assigned a separate portion of memory based on the configured value in your operating system.
***Caution Note***
If you want to increase the amount of memory allocated it can be done, but must be done with extreme caution as the parameter is extremely important for some basic system things and will prevent your operating system from starting properly.
The key that you are looking for is:
System\CurrentControlSet\Control\Session Manager\SubSystems\Windows
In this value there is a SharedSection=xxxx,yyyy,zzzz portion that you will be particularly interested in. x, y and z correspond to the desktop areas that I described above (1,2,3). By default these will probably be something like SharedSection=1024,3072,512. For most users this is more than sufficient. Microsoft does not recommend setting the second value higher than 5120 (5MB).
I currently have my system set to SharedSection=2048,8192,1024. I have been running with these settings on multiple systems for over two years.
Changing these values will obviously require a restart of your system to take effect.
A couple of caveats, the total memory for all desktops cannot exceed 48 MB. Also the more memory you allocate for the Non-interactive setting, the fewer services you can run. This is also true for the Interactive setting, which limits the number of Terminal Services sessions that you can run.
You may be again asking yourself the question posed above, "How would you ever practically need so many 'windows'?" Well, as you run multiple instances of more complex programs you start to use a good number of windows. How many you ask? Well for instance Visual Studio 2005 with a small solution open and two files consumes 186 windows. And each additional opened file in VS 2005 consumes more than 70 "windows". IE 6 with this site loaded consumes 16. So as you work on multiple projects of greater complexity and have multiple IE windows open and Notepad windows and Windows Explorer windows, you start to bump into the ceiling.
My experience is that 512 KB allows for about 1500-2000 windows depending on other system conditions. With the default setting of 3192 this allows for 9000-12000 windows. Again for most users, this is sufficient, but for a developer it might not be. With my setting of 8192 this allows me to have a window load of 24000-32000.
My experience is that 512 KB allows for about 1500-2000 windows depending on other system conditions. With the default setting of 3192 this allows for 9000-12000 windows. Again for most users, this is sufficient, but for a developer it might not be. With my setting of 8192 this allows me to have a window load of 24000-32000 which is plenty for what I need to do.
If you want more details, please see the links below, where I obtained most of my information in addition to the information that was obtained from Microsoft Technical Support.
http://support.microsoft.com/kb/126962/
http://support.microsoft.com/kb/184802/
No comments:
Post a Comment