Bug 106058 - Antialiasing memory leak
Summary: Antialiasing memory leak
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.1.1   Edit
Assignee: Silenio Quarti CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
: 114336 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-08-04 10:59 EDT by Olivier Chalouhi CLA Friend
Modified: 2005-10-31 12:31 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Chalouhi CLA Friend 2005-08-04 10:59:38 EDT
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.
Comment 1 Silenio Quarti CLA Friend 2005-08-04 12:21:02 EDT
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();
	}
}
}
Comment 2 Olivier Chalouhi CLA Friend 2005-08-04 13:38:32 EDT
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();
  }
}
}
Comment 3 Olivier Chalouhi CLA Friend 2005-08-04 13:49:23 EDT
I can still reproduce the bug with swt-N20050804-0010-win32-win32-x86
Comment 4 Silenio Quarti CLA Friend 2005-08-05 10:54:26 EDT
Thanks Olivier. The problem is that Pen.GetBrush() returns a copy of its brush.

Fixed > 20050805.
Comment 5 Silenio Quarti CLA Friend 2005-08-30 11:24:13 EDT
Fixed in 3.1.1 maintenance stream.
Comment 6 Silenio Quarti CLA Friend 2005-10-31 12:31:14 EST
*** Bug 114336 has been marked as a duplicate of this bug. ***