Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 724
Micky Avatar asked Mar 15 '12 15:03

Micky


People also ask

What is GDI objects?

The Graphics Device Interface (GDI) is a legacy component of Microsoft Windows responsible for representing graphical objects and transmitting them to output devices such as monitors and printers.

What are GDI objects in mfc?

It provides pens to draw lines, brushes to fill interiors, and fonts to draw text. MFC provides graphic-object classes equivalent to the drawing tools in Windows. The table below shows the available classes and the equivalent Windows graphics device interface (GDI) handle types.

What is GDI handle?

What are GDI Handles? GDI stands for Graphical Device Interface and every process that displays graphical objects and formatted text uses it. By default, each process has a limit of 10 000 GDI handles. Just like when CPU usage is high or available RAM is low, your computer can become unstable, when GDI handles run low.

How do I find a GDI leak?

Leaking GDI objects can be seen from the task manager or from Process Explorer. (Well you don't see the leaks, but you can see if object uasage count continually goes up.) There are also tools that allow to view GDI objects by type, such as GDIView[a], DeLeaker, DPUS or the GDIDebug (sourecode).


2 Answers

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?
like image 198
Derek Park Avatar answered Sep 23 '22 18:09

Derek Park


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.

like image 40
JimR Avatar answered Sep 23 '22 18:09

JimR