0

we are having GDI resource leaks that cause from time to time "Win32Exception Not enough storage is available to process this command" (related question).

Our application is composed from a Word Addin and a C# application. Can a leak in the Word addin remove the resources from the C# application? We have seen the application crash after some unrelated Addin problems.

In other words, are GDI resources allocated exclusively per process or are they shared somehow?

Community
  • 1
  • 1
Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207
  • 1
    Yes, GDI objects are allocated from the desktop heap which is shared by all processes that run on that desktop. Size is limited to 64K objects on an interactive desktop for appcompat reasons. But you can't exhaust it with just one bad process that leaks, it takes several. So doubtful that you found the real reason. Otherwise very easy to see in Task Manager, use View > Select Columns to add the "GDI Objects" column. – Hans Passant Nov 20 '15 at 10:11

1 Answers1

2

The exact number can depend on the version of windows but is generally a theoretical limit of 65,536 per session. In reality this is lower (e.g. 16,384 in Windows 2000).

There is also a per process limit of about 10,000 handles though this can be globally changed via the registry setting HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\GDIProcessHandleQuota. Though this setting shouldn't be changed by an application since its a global setting for the computer.

MSDN - GDI Objects

Old New Thing - Why is the limit of window handles per process 10,000?

Chris Chilvers
  • 6,429
  • 3
  • 32
  • 53