SWTGraphics2D not freeing up resources

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
MP3HiFi
Posts: 12
Joined: Fri Apr 11, 2008 8:02 am

SWTGraphics2D not freeing up resources

Post by MP3HiFi » Mon Apr 21, 2008 1:41 pm

Hello,

after a large Test (creating more than 1000 charts in an Eclipse plugin) I have figured out a problem using Sleak-PlugIn. There are fonts created in the class but they are not disposed, when the SWTGraphics2D is disposed.

I added two methods which are called from dispose() analog disposeColorPool:

private void disposeFontsPool() {
for (Iterator it = this.fontsPool.values().iterator(); it.hasNext();) {
org.eclipse.swt.graphics.Font resource = (org.eclipse.swt.graphics.Font) it.next();
resource.dispose();
}
this.fontsPool.clear();
}

private void disposeColorPool() {
for (Iterator it = this.colorsPool.values().iterator(); it.hasNext();) {
org.eclipse.swt.graphics.Color resource = (org.eclipse.swt.graphics.Color) it.next();
resource.dispose();
}
this.colorsPool.clear();
}

After that the resources are freeing up. Who is responsible to change the code.

Bye
Martin

heprom
Posts: 91
Joined: Sat May 27, 2006 4:25 am
Location: Paris

Post by heprom » Sat May 24, 2008 10:13 pm

Hi Martin,

which version of the code are you using? I've been out of the loop for a couple of months now being overcommited elsewhere. I think the last code from svn is fine, being basically very similar to your suggestion. Comments are welcome, thanks again.

Henry

MP3HiFi
Posts: 12
Joined: Fri Apr 11, 2008 8:02 am

Post by MP3HiFi » Mon May 26, 2008 12:30 pm

Hi Henry,

I have the latest version (1.0.9) from the build on sourceforge.

The revision 1014 from svn never disposes any color or fonts. It only disposes the resources, but thats not all.

Martin

Locked