Bug 105849 - SWT bugs: GDI Handles leak
Summary: SWT bugs: GDI Handles leak
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Silenio Quarti CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-02 15:56 EDT by Yasser Lulu CLA Friend
Modified: 2005-08-30 11:19 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yasser Lulu CLA Friend 2005-08-02 15:56:10 EDT
Running Eclipse SDK
Version: 3.1.0
Build id: I20050617-1618

Some GDI objects are allocated but never released eventually causing 
SWTError: No more handles


(1) Class:    org.eclipse.swt.graphics.Image
    Method:   int[] createGdipImage()
At the very end of creating an icon, the following code lines:
        if (iconInfo.hbmColor == 0) OS.DeleteObject(iconInfo.hbmColor);
        if (iconInfo.hbmMask == 0) OS.DeleteObject(iconInfo.hbmMask);
should be simply changed to:
        if (iconInfo.hbmColor != 0) OS.DeleteObject(iconInfo.hbmColor);
        if (iconInfo.hbmMask != 0) OS.DeleteObject(iconInfo.hbmMask);

(2) Class:    org.eclipse.swt.graphics.GC
    Method:   void fillGradientRectangle()

These two Colors are allocated:
       int fromGpColor = Gdip.Color_new(data.alpha << 24 | rgb);
       int toGpColor = Gdip.Color_new(data.alpha << 24 | rgb); 
However, wrong parameters are passed for their release:
     Gdip.Color_delete(fromColor); //this is the text color value not Handle!
     Gdip.Color_delete(toColor);//this is the background color value not Handle!

Please note that the above leaks happen every time the screen gets painted an 
an icon is there or a shape with gradient fill is enabled. The leaked handles 
add up quite quickly and crash Eclipse.
Comment 1 Billy Biggs CLA Friend 2005-08-02 16:07:21 EDT
The second problem was already fixed for 3.1 under bug 101795.
Comment 2 Silenio Quarti CLA Friend 2005-08-02 16:12:20 EDT
Fixed 
Comment 3 Silenio Quarti CLA Friend 2005-08-02 16:12:35 EDT
Fixed > 20050802.
Comment 4 Billy Biggs CLA Friend 2005-08-02 16:14:46 EDT
Seems like a good 3.1.1 candidate.
Comment 5 Steve Northover CLA Friend 2005-08-02 16:46:58 EDT
Did you check all places where ICONINFO was used?
Comment 6 Silenio Quarti CLA Friend 2005-08-30 11:19:59 EDT
Fixed in 3.1.1 maintenance stream.