10,000 GDI objects ought to be enough for anybody

The famous quote by Bill Gates, “640K ought to be enough for anybody”, stating that nobody would ever need more memory in a computer still is a good laugh. (Bill has denied making this remark, but the rumors say he did say that.) Anyways, about 20 years after that quote was born I was confronted with a new lunatic limit made by Microsoft. Let me rephrase the most famous quote:

10,000 GDI objects ought to be enough for anybody.

What are GDI objects? GDI stands for graphical device interface resource and it’s basically what you see on your screen. To example it, every app you run on your Windows™ computer wants to display at least some text that requires a font. That font is not just there and it’s not available in unlimited quantity. It occupies an operating system resource, in other words: it requires some memory.
Ages ago, computers where never expected to have more than 640K of that precious memory. ;-) Memory still is a precious resource and many computers sold today are just equipped with the bare minimum. But still, it is plenty compared to the mid ages of computing. But not for Microsoft as they limited the number of GDI objects per process to 10,000 on Windows 7 although there is a theoretical upper bound of 65,536.

Well, of course I hit that limit lately, otherwise I wouldn’t be writing this blog post right now. I am a software developer and architect using a couple sometimes very memory consuming tools. One of that very memory consuming tool is the Eclipse IDE with the Papyrus UML 2 plug-ins.

I was designing an application and created lots of diagrams which took me a couple of hours. Apparently at random Eclipse crashed by freezing, sometimes after 2 hours, sometimes after 4. There was no exception in the error log about the reason of the crash. Just once, I’ve seen an SWTException coming from the tabbed properties page saying something about “out of OS resources”. The only tool/plug-in that was using the properties view was the Papyrus UML tool. But no Papyrus class appeared in that one stack trace that I’ve seen.

Searching for a bug entry and Google I couldn’t find anything related to this. But a co-worker was lucky. He found similar reports by Adobe users and this link to a Microsoft page. To verify the GDI limit being the cause of my Eclipse crashes I downloaded the Sysinternals Suit. It contains a lot of useful administrative tools for Windows™ including the Process Explorer.

The Process Explorer lists all running processes and in the details it shows the number of GDI objects active per process. I started Eclipse, created a new UML diagram using Papyrus, and checked the number of GDI objects. The value was roughly 960. Two hours later Eclipse froze again. I checked the number of GDI objects in the Process Explorer. It was 9986 which was not far from the limit.

Clearly, working with Papyrus in Eclipse creates more and more GDI objects. I’m not too keen on further digging into this, well, I call it “bug or memory leak in Eclipse/Papyrus related to the tabbed properties page”. At least not until I hit the theoretical limit of GDI handles, because the above link to the Microsoft page points to a registry key that sets that limit. I changed it to the theoretical maximum and that seems to be enough to keep Eclipse running and Papyrus working for a regular 8-hour day.

So, keep in mind:

65,536 GDI objects ought to be enough for any Windows™ user!

3 comments to 10,000 GDI objects ought to be enough for anybody

  • I just filed a bug report for Papyrus: bug 355337.

  • Simon

    There’s another quirk where an individual process can only address every other handle – so actually, it’s 32,767 for any individual process.

    I have to say that personally, I think letting an individual process have access to ~1/6.5 of a resource with a hard limit is pretty generous. If only it weren’t for backwards-compatibility with 16-bit processes, we could kick this limit forever…

  • Johnson & Johnson

    There is no 16-bit Win processes in win7.

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>