What's the upper limit on GDI objects for one process in Windows 7?

梦想与她 提交于 2019-12-17 09:43:45

问题


Have an application with a GDI leak that will eventually hit 10,000 allocated GDI objects and crash. I tried increasing the GDIProcessHandleQuota to 20,000, but the program still crashed when it reached 10,000 objects. We're currently working on patching this leak, but out of curiosity--is there a way to increase the GDI limit for a single process? Or is 10k an individual application's hard limit?


回答1:


There is a solution that might work. I deal with a misbehaved vendor's app here that allocates tons of GDI objects and this solution allows it to work most of the time...

Do

reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems" /v windows

Look for SharedSection= which should be 3 numbers separated by commas. Increase the middle number by 1024 at a time and see if that solves your problem. You are controlling the amount of "desktop heap" with this variable which has in the past allowed me to get a misbehaving GDI running.

Look at KB184802 for a little more info. Search for SharedSection to find the relevant part of the page.




回答2:


10K is a hard limit.

GDI objects represent graphical device interface resources like fonts, bitmaps, brushes, pens, and device contexts (drawing surfaces). As it does for USER objects, the window manager limits processes to at most 10,000 GDI objects [...]

Mark Russinovich has a series of articles that go in-depth about the various limits in Windows. You might find these two useful:

  • Pushing the Limits of Windows: USER and GDI Objects – Part 1
  • Pushing the Limits of Windows: USER and GDI Objects – Part 2

Another good article from Raymond Chen:

  • Why is the limit of window handles per process 10,000?



回答3:


I am able to increase my GDI objects from 10000 to 15000 by changing ONLY the GDIProcessHandleQuota, but this requires a reboot to take effect. I did not have to change my SharedSection values, only the reboot was required.

While 10000 seems like a big number, my application has a large UI with lots of buttons, brushes, images, icons, etc. Once the application starts up, the number of objects only increases if the user does something that merits an increase. No GDI objects are leaking from the application. To test my solution I did add a "leak" method, so I could watch in the task manager what happened as the number of GDI objects increased beyond various limits.



来源:https://stackoverflow.com/questions/9723470/whats-the-upper-limit-on-gdi-objects-for-one-process-in-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!