Community
Participate
Working Groups
Build ID: M20060921-0945 Steps To Reproduce: 1. Create a small SWT project 2. Open the windows task manager, make the GDI object column visible 3. Add FontData fontData = getFont().getFontData()[0]; to the code 4. Debug to the inserted line, when you step over the GDI object count is incremented but there is no possibility to free the temporary created GDI handle More information: The problem is the implementation of getFontData: if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); LOGFONT logFont = OS.IsUnicode ? (LOGFONT)new LOGFONTW() : new LOGFONTA(); OS.GetObject(handle, LOGFONT.sizeof, logFont); return new FontData[] {FontData.win32_new(logFont, device.computePoints(logFont, handle))}; The handle created by OS.GetObject is not disposed.
Here is the description of GetObject() from the MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_912s.asp
GetObject() doesn't create a HANDLE. Can you reopen this bug report with some sample code that is leaking? (a small, stand alone SWT snippet?)
Sorry I didn't have a further look on what GetObject does. I did some debugging with the SWT source. The problem is not GetObject but the function Device.computePoints which is called by getFontData. Take a look on the source code: float computePoints(LOGFONT logFont, int hFont) { int hDC = internal_new_GC (null); internal_new_GC calls GetDC(0) which creates a windows device context and therefore creates a GDI object - which can be seen in the task manager. This device context is not freed by computePoints.
Great catch!!! This code was introduced recently so the leak is new to Eclipse 3.3 M4.
Fixed > 20061214 (NOTE: The fix will be in Eclipse 3.3 M4)
Thank you so much for finding and reporting this bug.