Login  Register

Re: JOGL SWT GLCanvas leaks SWT Color

Posted by badjames on Jun 30, 2025; 10:22am
URL: https://forum.jogamp.org/JOGL-SWT-GLCanvas-leaks-SWT-Color-tp4043707p4043804.html

Hi Sven,

Due to the Eclipse RCP application I am developing for, we are using an older version of SWT.  Specifically, SWT 3.110 which I think was released along with Eclipse 4.10.

That older 3.110 version still needs Colors to be disposed, as evidenced by the fact that all the constructors require a Device object.

I have added a custom version of JOGL 2.5.0 GLCanvas to my code that sets the background color to white using the system color, which is pre-allocated (and managed) by SWT:

setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));

This removes the Color leak as detected by S-Leak and also prevents the GDI object leak I was seeing in Process Explorer.

As this is fixed in later versions of SWT, I'm not suggesting that JOGL needs to change.  Probably unlikely that other people would be using such an old version of SWT.

Cheers,

James