探索与发现

研究java技术

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  83 随笔 :: 0 文章 :: 109 评论 :: 0 Trackbacks

Have you ever been working with a good number of applications at once? Are you a naturally born multi tasker? Alright, answer me this - who has had Windows buckle under the weight of all of these applications and display error messages stating that the system is out of memory or out of resources, buttons and menus do not work correctly, or you get an error sound but no message on the screen? I’ve hit this numerous times, to the point that I’ve lost work because of it…

(By the way, Adobe, can you please implement that little feature that Microsoft Office has had for years known as “auto save”? I don’t know how many times I’ve managed to completely max out Windows designing a web site and have had Photoshop fall over dead and disappear off my screen, only to find out that when I open Photoshop up again that the entire thing saved jack-all, all of those layers and documents gone poof into the void of darkness… if Microsoft can do it, why can’t you?)

Sometimes this happens even when you have a lot of system memory (RAM) still available. For instance, open up Internet Explorer and hold Ctrl+N to open up as many Internet Explorer windows as you can before menus, icons, and menus start displaying incorrectly, disappear, buttons aren’t clickable, etc. Close a few out and check your Windows Task Manager in the “Performance” tab, I bet you will find that a lot of your Physical Memory is still available.

This publication applies to:

    * Microsoft Windows 2000 Professional
    * Microsoft Windows 2000 Server
    * Microsoft Windows 2000 Advanced Server
    * Microsoft Windows XP Home Edition
    * Microsoft Windows XP Professional
    * Microsoft Windows XP Professional x64 Edition
    * Microsoft Windows XP Media Center Edition
    * Microsoft Windows XP Tablet PC Edition

DISCLAIMER: mikedopp.com and mikedopp hold no responsibility or liability whatsoever should something go wrong, or if you incorrectly modify the Windows Registry. Please take extreme caution while following this publication and follow the steps correctly.

“Okie-dokie, if I have all of this memory still available, why is Windows saying I’m out of memory and out of system resources!?”

Simple. You have hit the “user handle” or “GDI handle” limit in Windows. This limit is there for two reasons:

    * Leaky applications or faulty code & malware can’t easily crash the system by attempting to overflow the system with GDI handles, making everything un-usable until a reboot is performed.
    * To prevent a user from opening up more applications than the system can handle.

If you have 1 gigabyte (or 1024MB) of RAM or higher, the default User Handle and GDI Handle limits can be pretty restrictive when running a large working set of applications that demand the most from your system and tax it heavily.

“Do you feel my pain?”

Yes, of course. Otherwise, I wouldn’t be writing this article that is more than likely a good 2 or 3 pages in length.

I’m a designer and coder, I use Adobe Photoshop with a lot of documents opened up - on top of that, I usually listen to music while working as it helps me work better, so Windows Media Player 10 is usually open on my machine. Also opened are Windows Messenger, Microsoft Office Outlook 2003, SmartFTP (one of the best FTP clients I’ve ever used, highly recommended), Microsoft Word, a few dozen Internet Explorer windows, some Mozilla Firefox windows with a few tabs opened in each one, and EditPlus 2 for coding.

That’s a pretty heavy working set of applications, and I demand the most out of my computer when it comes to multitasking (I have a Pentium 4 2.66GHz, with 1.5GB of RAM just for those who are wondering).

I too have nailed these handle limits - more than once. After much searching and pondering I have finally come up with a working solution around this issue (hurray!)

“Yeah yeah, stop rambling and cut to the chase!”

First and foremost, I must warn you that modifying these settings incorrectly can render your Windows installation near useless. Also, depending on your computer configuration and the amount of RAM in your system, you may wish to play around with the numbers until you find a setting that is perfect for your computer.

To back up everything, open the Registry Editor (click on Start, Run, and then type “regedit.exe” (without the quotes).

To backup a registry key:

    * In the Registry Editor on the left hand side, you will see the navigation pane. Using your mouse or keyboard, navigate to the following subkeys:

    * HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems 
    * HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Windows 
    * Right click on each of the subkeys above in the left hand pane and from the context menu that appears, choose the “Export” option. Save the exported registry data file where ever you wish, but make sure that it will be accessible should we need to restore the files.

“OK, I’ve backed everything up! Now what!?”

Don’t quit the Registry Editor just yet - we still need to make some modifications in order to increase the handle limits in Windows.

With the Registry Editor opened, navigate to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems. You will notice a set of “REG_MULTI_SZ” and “REG_EXPAND_SZ” keys in the right hand pane. The one that we are interested in modifying is called “Windows”.

To modify the key, double click on it. It should look something like this:

    %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

The section of this string we are interested in modifting is “SharedSection”.

In the SharedSection part of the string you will notice 3 numbers. What we are interested in is the middle value, “3072?. Modify this value so that the middle number is “8192?.

It should look something like this after modifying the value:

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

Now that we’ve changed this, lets continue, shall we?

In the left hand pane of the Registry Editor, navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows. In the right hand side, you will see two REG_DWORD values, named “GDIProcessHandleQuota” and “USERProcessHandleQuota”. We will need to modify both of these.

The first key we will want to modify is “GDIProcessHandleQuota”. This keys value can be set between 256 and 16,384 (maximum), and the default value is 10,000. I’d recommend using 15,000 as a value for this key, however if you are doing a lot of multitasking, shoot for the stars and go with 16,384.

This key can not be set past 16,384 as it is the maximum acceptable value.

Now, lets modify “USERProcessHandleQuota”. This keys value can be set between 200 and 18,000 (maximum), with a default value of 10,000. I’d recommend increasing this value to the same number used with “GDIProcessHandleQuota”, however as previously mentioned if you are working with a hefty application workload, shoot for the stars and go wth the maximum value of 18,000.

This key can not be set past 18,000 as it is the maximum acceptable value.

Do NOT attempt to increase these values past the maximum - Windows will become very unstable and may even stop working correctly. If Windows starts acting up after changing these values, lower them until the issues are resolved, or restore the backups of these keys’ values that we created before making modifications.

Now that you’ve changed these values, restart your computer and tax the system using the Internet Explorer trick mentioned previously - open Internet Explorer and hold down Ctrl+N on your keyboard to open up new Internet Explorer windows. Continue this until menus, buttons, and user interface elements stop working correctly. Also, open any applications you run day-to-day while you are performing this, so that you can get more of an idea if you have everything configured correctly.

You may also want to monitor your memory usage and handles information in Task Manager to see whether or not the above registry values need any more modifications.

I hope this helps with any multi-tasking issues you may have run into while running Microsoft Windows, now get back to work!

posted on 2008-08-31 20:53 蜘蛛 阅读(479) 评论(1)  编辑  收藏 所属分类: java日常琐事

评论

# re: Increasing User Handle and GDI Handle Limits [未登录] 2009-02-11 06:50 test
http://www.codeplex.com/threetierwss  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: