Ohad's Blog

Lets talk about .net !

Mirror at:
blogs.microsoft.co.il

News

         Ohad Israeli's Facebook profile

Grab this badge here!

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

Erez said:

Hi all,

I am using a trading system to open up hundred of windows. The systems stops opening new windows at 440 windows.I would like to be able to 800 windows. Can some please help me solve the mystery. I'm using windows xp pro.

Thanks.

# June 5, 2008 9:40 PM

mssolver said:

Default Values are :

Vista32bit: 12MB

Vista64Bit: 20MB

XP32Bit: 03MB

XP64Bit: 20MB

# June 10, 2008 4:08 AM

Sydney Bloom said:

Thank you so much. Mine was already 512. so i altered it to the 4096? I'm looking forward to that changes. I am also glad i'm not the only one whom uses multiple windows. I use it for research.

Explorer can be crashed by me on a brand new computer.

*i've been to bestbuy and Blue screened all thier computers*

Sydney+

# July 1, 2008 4:33 PM

Christopher said:

It does not work. I do not believe that the above statements are true, as this limitation is the product.

# September 3, 2008 5:44 PM

Itsme said:

Christopher, it works.  I've been doing this for years.

Everyone, There are other things that you can do in addition to this if you need to open a lot of windows.  I've forgotten exactly the names of the registry keys, but it involves increasing the maximum GDI objects, and maximum user objects.

There is one more thing you can do.  The shared section mentioned above comes out of a 48 mb buffer (on 32-bit operating systems).  You can increase that number, but I can't remember the parameter.

To Ohad Israeli, I highly recommend increasing the number to greater than 4 MB if you intend to open a lot of windows.  I personally always use 12 MB because I routinely have 200 - 400 windows open.  However 4 MB provides a huge boost over the default.

I do want to disagree with one statement that you made.  You state:

===

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.

===

While that is technically true behind the scenes, the average user simply sees that a window does not open, with no error message at all.  Only if a program properly handles the error message will the user see the error.  Even Internet Explorer does not show an error message.  In addition, even if a program attempts to properly handle the error message, it might not be able to as it may be unable to open a window in which it can display the error message.

# October 9, 2008 1:10 AM

George E. said:

Sweet!  I work in multiple RDP windows while administering servers, and it looks as if those 'desktops' get built using this as well.  Good find, sir!

# November 12, 2008 9:00 AM

Greenville IT Support said:

The registry value that allows you to enlarge the 48MB buffer is SessionViewSize.  Don't go crazy with it, but you can set it to 64 or 96 MB.  Then you could set your shared section to 24MB.

A couple of people spoke about the number of windows open becoming less over time.  This is very true and is caused by memory leaks.  Some of the leaks are from other programs and some are in Internet Explorer.

It's easier for me to give you an example of how to reduce this problem than for me to give you the rules.

Case 1.  You open up a window with 10 tabs, then you close them all so that internet explorer closes.  You do this 10 times so that in all you have opened up 100 windows, but the last time you leave all 10 windows open.  You look in task manager and see that internet explorer is using 100 MB (this is just a made up number to illustrate the point).

Case 2.  You open up a window with 10 tabs, then you close 9 of them, then you open up another 9, then you close those 9, until in the end you have opened up 100 total windows, and you have 10 of them open now.  You look in task manager and you see that internet explorer is using 150 MB.

What you are looking at is a memory leak.  Just like the memory is leaking, so are the maximum number of open windows.  You don't recover that number until THAT instance of internet explorer is closed.

# November 13, 2008 5:55 PM

INSAR said:

Umm... I have the '2137980928'. And what should I do?

(Win XP SP2)

# January 18, 2009 3:12 AM

Anand More said:

I am working in Software Company. In one of my project we have a calendar control which opened in new window when user clicks on the Cal. Icon.

The calendar is working on our machine/ environment but the calendar is not working on client machine which has a Vista installed. I tried my best but the issue is not resolved.

We use window.open to open the calendar but the system throws the error when execute this statement.  Now I will suggest to my client to do this modification in your registry by referring this blog then let us see what happen.

# February 25, 2009 1:55 AM

4evermaat said:

I can confirm that this works.  I had windows server 2003 (32 bit)and was running multiple demos to test multiple strategies.  After a few programs were open, I saw the slowdown.  I tweaked the middle setting to 8032 and I was able to run many more demos.  I will try increasing it further as I want to nearly max out my system resources.  I was using a quad core with 2 gig ram.  

Would have been a waste if i didn't find this tweak to have so much system resources but couldn't use them.

# June 17, 2009 4:34 PM

Abo said:

I'm having the same issue with windows vista. After a while, the only way to get rid of the problem is to restart windows. I tried to find the key listed but couldn't find it in my regedit. the closed one is:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems\CSRSS\CsrSrvSharedSectionBase

it's set to 2137980928 any idea?

# August 11, 2009 12:57 AM

Jens Leinenbach said:

Here are some useful details from Microsoft:

support.microsoft.com

# August 27, 2009 12:57 PM

Windows XP ???????????????????????????????????????????????????????????? | ??????e??? said:

Pingback from  Windows XP ???????????????????????????????????????????????????????????? | ??????e???

# September 29, 2009 9:39 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)