Community
Participate
Working Groups
SWT 3138, WinXP : When setting the antialising using either : gc.setAntialias(SWT.ON); or gc.setTextAntialias(SWT.ON); the application leaks (at a rate of approcimately 300kB/s => 20MB is leaked every minute) I experience the leak from the windows taks manager, GDI objects is constant, same with handles, but memory keep raising. If I turn off the antialiasing in the application (while debugging with eclipse), the leak stops, if I turn it back on, the leak comes back.
I could reproduce this problem using this small test. I was not able the reproduce it either by hacking GC.init() to call setAntialias(SWT.ON) and run Eclipse. We have fixed some leaks (see bug#101795 and bug#105849) in the latest integration build. bug#105849 is probably unrelated to your problem, since it is a GDI objects leak. Please could you try the latest and/or provide a testcase that shows the problem? import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; public class PR106058 { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { GC gc = event.gc; gc.setAntialias(SWT.ON); for (int i = 0; i < 1000; i+= 3) { gc.drawLine(i, 10, i, 300); } } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }
Ok, I made some more investigation (with 3038), and here's a snippet which triggers the problem. It appears that the problematic method is drawText : Run this snippet, and resize the method (to trigger the paint event), you'll leak many MBs per sec. I'm going to test it against the latest nigthly build and see if the issue is fixed. import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; public class PR106058 { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { GC gc = event.gc; gc.setAntialias(SWT.ON); for (int i = 0; i < 1000; i+= 3) { gc.drawText("" + i, 5,5); } } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }
I can still reproduce the bug with swt-N20050804-0010-win32-win32-x86
Thanks Olivier. The problem is that Pen.GetBrush() returns a copy of its brush. Fixed > 20050805.
Fixed in 3.1.1 maintenance stream.
*** Bug 114336 has been marked as a duplicate of this bug. ***