Monday, October 25, 2010

Increase the maxiumum number of windows in Windows!

I tend to keep a lot of windows open on my main desktop (Windows XP). Right now I have 21 windows -- that's a low number for me actually, because I had to reboot recently after a software install.

As time goes by, I accumulate more and more windows. Eventually, when I try to open a new window, I find that either 1) nothing happens or 2) the window opens, but it's missing vital elements (menu bar, icons, etc.).

It turns out that this is due to Windows running out of space in the "desktop heap" (If I understand correctly! See this MSDN article). The default size of the heap is 3072 KB in XP (the default is larger in Vista and Windows 7). Obviously this is not enough for me, so I edited the registry as described in the MSDN article (here's another article with more explicit instructions). I changed 3072 to 8096. (note: you must reboot for changes in the heap size to take effect; logging out and back in is not sufficient)

Now I can open more windows without any of the interface issues I was seeing before. At least, I haven't run into any issues again since I made the registry edit.

For the intensely curious, you can see the current size of your desktop heap using a debugging tool from Microsoft called "Desktop Heap Monitor"

After you unzip the download, you have to install it manually from the CMD prompt:
C:\dheapmon8.1\x86>dheapinst.exe -y %SYSTEMROOT%\Symbols
  dheapinst - Desktop Heap Monitor installed successfully

(The installer seems to copy the necessary files to %SYSTEM32%\kktools)

Then, load the heap driver with "dheapmon -l"

Now you can see your heap:
C:\WINDOWS\system32\kktools>dheapmon
Desktop Heap Information Monitor Tool (Version 8.1.2925.0)
Copyright (c) Microsoft Corporation.  All rights reserved.
-------------------------------------------------------------
  Session ID:    0 Total Desktop: ( 10848 KB -    8 desktops)

  WinStation\Desktop            Heap Size(KB)    Used Rate(%)
-------------------------------------------------------------
  WinSta0\Default                    8096             29.1
  WinSta0\Disconnect                   64              4.5
  WinSta0\Winlogon                    128             17.8
  Service-0x0-3e7$\Default            512             29.6
  Service-0x0-3e4$\Default            512              6.3
  Service-0x0-3e5$\Default            512             10.8
  SAWinSta\SADesktop                  512              0.5
  Service-0x0-2a22a$\Default          512              2.5
-------------------------------------------------------------

No comments:

Post a Comment