問題描述
一個進程的 GDI 洩漏會影響其他進程嗎? (Can GDI leaks from one process affect other processes?)
我們遇到 GDI 資源洩漏,不時會導致“Win32Exception 沒有足夠的存儲空間來處理此命令”(相關問題)。
我們的應用程序由 Word Addin 和 C# 應用程序組成。Word 插件中的洩漏是否可以從 C# 應用程序中刪除資源?在一些不相關的插件問題之後,我們已經看到應用程序崩潰。
換句話說,GDI 資源是按進程獨占分配還是以某種方式共享?
參考解法
方法 1:
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.
Old New Thing ‑ Why is the limit of window handles per process 10,000?
(by Ignacio Soler Garcia、Chris Chilvers)