Community
Participate
Working Groups
Created attachment 98081 [details] Screen shot of Sleak showing the 2 leaked Color objects I'm seeing a Color leak when using GMF based editor with a palette. The leak is being detected with the use of Sleak. Everytime I close the editor, I see an increase of 2 for the Color objects. The Color being leaked appears to be the Color returned as a result of mixing PaletteColorUtil.WIDGET_BACKGROUND and PaletteColorUtil.WIDGET_NORMAL_SHADOW. See below. See ToolbarEditPart: graphics.setForegroundColor(FigureUtilities.mixColors( PaletteColorUtil.WIDGET_BACKGROUND, PaletteColorUtil.WIDGET_NORMAL_SHADOW, 0.7)); I've poked around with the ToolbarEditPart code and ensured I disposed of the mixed Color object in the deactivate() method. When this is done, I don't see the leak. Please see the two screenshots I will attach.
Created attachment 98082 [details] Screencap of ToolBarEditPart.java and the code which creates the leaked Color objects.
According to the discussion in Bug 68979 I do not need to dispose Colors.
(In reply to comment #0) > I'm seeing a Color leak when using GMF based editor with a palette. The leak > is being detected with the use of Sleak. Everytime I close the editor, I see > an increase of 2 for the Color objects. Does this mean after you open and close the editor 4 times you have 8 Color objects? Or do you only have 2?
(In reply to comment #3) > (In reply to comment #0) > > I'm seeing a Color leak when using GMF based editor with a palette. The leak > > is being detected with the use of Sleak. Everytime I close the editor, I see > > an increase of 2 for the Color objects. > Does this mean after you open and close the editor 4 times you have 8 Color > objects? Or do you only have 2? I would have 8 Color objects. I've also noticed an increase of 5 Color objects with the following scenario: 1)Open the editor (the palette will be shown) 2)Hide the palette 3)Reshow the palette 4)Close the editor If I run through the above scenario 4 times, I see a total increase of 20 Color objects.
Created attachment 98445 [details] Proposed fix. I have moved all the calls in the new Palette code where new Colors are created with FigureUtilities to the PaletteColorUtil class and declared them as static so that only one Color object will only ever be created for each of these. Anthony -- this is ready for review. FYI -- There is a bugzilla open against SWT to clarify whether new Colors need to be disposed or not. See Bug 164051.
Colors are not resources and do not need to be disposed. There is a bugzilla open against Sleak requesting that it filter our Colors: bug 164026.
Committed to HEAD