Ohad's Blog

Lets talk about .net !

Mirror at:
blogs.microsoft.co.il

News

         Ohad Israeli's Facebook profile
      

C# Code Snippts

Favorite Blogs

Israeli .Net Bloggers

Max Num. of Open Windows under XP/2003/VISTA - Resolved !

When I'm working (it happens from now and then...) I always tend to open lots and lots of explorer windows as I Google for answers to questions that come along while coding...

When I used XP and Win 2003 it always bothered me that as soon as I opened 15-17 Internet explorer windows my system got stuck so hard that even right click context menu wouldn't seem to show up.

When I migrated to Vista I though that finally someone in MS will fix this limitation but I was disappointed to find out that it still there...

Well after looking and looking... searching and hacking ... I found the answer !

Its all about the desktop heap !

Following is Desktop Heap Tweak:

Because it is an undocumented registry tweak I take no responsibility regarding implementing this tweak ! It worked for me and if you choose to tweak your system you are doing it on your own risk.

Longtime Windows users are familiar with the desktop heap, a memory space that Windows allocates for desktop objects such as, well, windows.

Each open window or other desktop object uses up a certain amount of the desktop heap. In older versions of Windows the desktop heap was very small, and objects weren't always disposed from the heap correctly.

This was a good part of the reason for the Incredible Shrinking Resource Heap problem that plagued the 16 and hybrid 16/32-bit versions of Windows.

NT fixed this problem by devoting a far larger chunk of memory to the desktop heap -- but the fact that it had a far better memory manager than Win 3.x or Win9x, and a pure 32-bit architecture, didn't hurt either.

The desktop heap limit affects the NT/VISTA family of systems, Hitting the limit is manifested as either a DLL initialization error for USER32.dll or an out of memory error.

Fortunately, the limit it tweakable, the default settings are low enough that the limit is easily hit.

To tweak the limit, take a look in the registry at HLKM/System/CurrentControlSet/Control/Session Manager/SubSystems

(cranked up a bit if you find yourself manipulating a lot of desktop objects.)

Within that key is a subkey called Windows, which contains in it, among other things, the value "SharedSection=1024,3072"

Changing the SharedSection entry to "1024,3072,512" (note the comma and the value)increases the size of the "hidden" desktop heap.

If that doesn't work, try increasing the second of the comma delimited values (e.g. 3072 -> 4096) which is the size limit of any particular desktop heap.

Update: just to clarify for some pepole... on vista your default is 1024,3072,512 changing is to 1024,4096,512 will make the difference

Comments

Mark C said:

Man.. you are an absolute star!! My messy style of working means that i've been plagued by this for years - nice one :-)

# February 6, 2007 8:39 PM

pluginbaby said:

Even with IE7 tabs ?

# February 6, 2007 9:45 PM

Ohad Israeli said:

Thanks Mark.

And yes after patching the registry you are able to open lots of IE7 tabs what wasn't working pirior to tweaking the registry.

# February 7, 2007 12:51 AM

Rajiv said:

My Vista had it by default

%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,3072,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16

Any ideas why?

# February 7, 2007 1:21 AM

Martin said:

On my windows xp professional sp2 latest patches this value is already set to 1024,3072,512!

# February 7, 2007 4:51 AM

Boris Yeltsin said:

Amazing. I've always had the same problem. I have to start using CTRL+TAB and ALT+F4 to get rid of a couple of windows so that I can actually work again. People are always gob-smacked when they see my desktop :)

# February 7, 2007 5:20 AM

Ohad Israeli said:

Rajiv,Martin,

I had the 1024,3072,512 already set on my vista too and changing it to 1024,4096,512 made the diffrence :)

# February 7, 2007 9:28 AM

Makoto said:

Thanks for the tip.  However, when I looked at my registry, mine is set to: 1024,20480,768

I'm running a clean install of Windows Vista Ultimate edition.  I have never modified this setting before, so I'm guessing it's the default value.  Wonder why it's different for everyone else on here.

# February 9, 2007 12:07 PM

Ron said:

hey, yeh ive got vista and mine was preset with the 512...however i changed the 3072 to 4096 and it seems to have worked a charmed

# February 10, 2007 9:17 AM

Raymond said:

i'm running vista ultimate and am facing this problem but only recently after i upgraded from 1GB memory to 2GB memory...great tip, will see if it works or not

# February 28, 2007 5:59 PM

john said:

worked for me too my limit was 32 open windows now it is at least 50

thanks for the tip

# March 4, 2007 3:20 PM

scott said:

I have the same as Makoto (1024,20480,768).  Running Windows Server 2003 x64.  I think there may be a 20MB desktop heap limit for each 'interactive' desktop (see http://blogs.msdn.com/ntdebugging/archive/2007/01/04/desktop-heap-overview.aspx).

# March 7, 2007 8:16 PM

James Ward said:

Hey there, I was just wondering if this is the problem I am having - I don't get any error messages - just Internet Explorer refusing to load any more tabs and new windows refusing to load unless i close some currently open ones and sometimes even menus refusing to display?  

It's odd though because I have only started to experience it in the last few weeks and my working habits haven't changed - I do have LOTS of windows open at a time though so...

In conclusion, does this problem lead to error messages as I don't get any!

# April 10, 2007 12:34 PM

Ohad Israeli said:

Yes James, this is exactly the prob.

And now you also know how to fix it :)

Ohad.

# April 10, 2007 1:18 PM

Peter said:

Man ytg

I googled this problem and found no answers, figuring that it was a program that i just installed that was causing the problem and had never had this happen to me I was going to reinstall XP with all my other programs. (yes i uninstalled that specifique program first). Just before i went ahead and did that, i made a last attemp at finding an answer to this issue, man i found your site.

thks a lot for posting this, saved me a days work of reinstalling all my stuff.

# April 21, 2007 9:21 AM

Peter said:

one more comment i set my Xp at  (1024,20480,768). up to 100 open windows and still going , cool

thks a lot, really

# April 21, 2007 9:34 AM

Concerned developer said:

I'm more concerned with trying to identify what my app is allowed to do under Vista when not logged as admin under these obviously tight restrictions.

# April 29, 2007 11:48 PM

Laurent Kempé said:

I was experiencing for some time a quite strange effect on my no so old installation of Windows Vista

# May 22, 2007 4:27 PM

Random user said:

Awesome.  I tried the value 1024,20480,768 and it seems 400 open windows was the highest before shit hit the fan.  I just held Alt f4 and after a while, back to normal!  Thanks

# July 17, 2007 2:29 AM

Action Vance said:

Holy crap!  Whats really funny about this is that for the longest time, I thought I was the only person experiencing the problem, or that it was something messed up on one of my systems.  I click, and nothing happens.  Then I noticed the same thing on my vista laptop.  

Damn!  I assumed that this was just some dumbass attempt at memory protection or preservation. Oh.  Wait.  it is.

Ohad - you rock!

# July 24, 2007 9:34 PM

don said:

unless you know to search on "desktop heap" this problem has been amystery for frar too many people for too many years...

but this article finally clears it all up:

blogs.msdn.com/.../desktop-heap-overview.aspx

btw that 20480 default is becuase  it's a 64 bit o/s

# September 14, 2007 8:25 PM

Oheretic said:

Well, I followed the info for windows Vista and its still happening!

Its a brand new computer and it keeps freezing me out! Any ideas anyone?

# October 25, 2007 9:32 PM

elleshar said:

This is a prayer answered.

Thank you for the solution and "heartbreak",a friend, for finding this link for me :)

# December 6, 2007 3:11 PM

Jeff said:

What about the disposal of objects? I've noticed that whenever I've hit this limit, and am unable to open additional windows, I then need to close more than one window to open up any additional. Thus, while my existing window count is decreasing, my new window count is not increasing by the same amount!

What's the downside to increasing this value? Or effect of each increment added?

"objects weren't always disposed from the heap correctly"

# December 21, 2007 7:45 PM

mdzieg said:

Can I set higher value than 4096 on 32bit Vista?

# March 6, 2008 4:45 PM

Ohad Israeli said:

Yes you can, mine is set for 10240.

# March 7, 2008 3:15 AM

AndyR said:

I'm running XPpro and the fix in this article still didn't help me.  What should I try next?  I see folks setting much higher values for Vista.. but how high can I go with XP?  (Current values are 1024,4096,512)

Also... what in the world causes this problem?  It's like my computer just refuses to release these handles.  I need to reboot every couple days because eventually I'm dwindled down to 3-4 windows and can't work anymore.  It's got to be a program I install.. because the problem has followed me on my last 2 brand new work computers.  No one else in my office has ever had this issue.  Is it just the way I work?

# April 7, 2008 8:31 AM

Explorer » Max Num. of Open Windows under XP/2003/VISTA - Resolved ! - Ohad’s… said:

Pingback from  Explorer » Max Num. of Open Windows under XP/2003/VISTA - Resolved ! - Ohad’s…

# May 12, 2008 4:57 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)