I am working in Java, using Eclipse as both IDE and platform. It’s fun and confuses people when I can run the thing i am working on in a separate editor in the same window of eclipse while editing the code in another editor tab in the same window. Confused yet?
Anyway not what I was writing about. I’m targeting Eclipse and using GEF (the Graphical Editing Framework) Draw2D and SWT. SWT is where the problems begin. SWT uses widgets and items that work with the underlying OS and Window Manager so that the look and feel is much like the rest of the programs on the target platform. So the handles and memory of the widgets being used are owned by the OS and so Java doesn’t automatically garbage collect them.
So you have to and it’s not always obvious. And you have to be careful that you don’t garbage collect them and then use them again or that you don’t garbage collect the item if you didn’t create it. It sounds simple and it is mostly. SO if you do something like
Color mycolor = new Color(null, 255,50,50);
then be sure somewhere after you use it you have
And if it’s someplace that you might reassign the mycolor with a new value then dispose the old before assigning a new one or you can change them instead of making a new one.
- Eclipse Announces Full Support for Java 7 (prweb.com)