I am trying to track down the cause of a Windows-only problem in my SWT application, which sometimes runs into the following error:
org.eclipse.swt.SWTError: No more handles
Tracing the line which throws this error reveals that it's calling the CreateWindowEx Windows API function, which can fail if there is not a GDI handle free.
The error occurs periodically when running tests against the application on one of our Windows Server 2008 build servers, over Remote Desktop.
I have so far found and fixed a number of leaks of SWT Image and Font objects, some of them resulting in hundreds of GDI handles leaked per invocation of the application.
However, I am struggling to verify (using a test application which deliberately uses lots of handles) that I've fixed the problem. My test application hits the per-process limit of 10,000 GDI handles. Running it serially doesn't cause a problem; running two or three of it simultaneously does.
So, at last comes my question:
Is it possible, under any circumstances, for a GDI handle on Windows to outlive the process which created it?
If so, is there a tool I can use to view the count of these 'leaked' GDI handles?