Bug 45640 - PENs are being leaked during painting
Summary: PENs are being leaked during painting
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P2 blocker (vote)
Target Milestone: ---   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2003-10-27 18:58 EST by Randy Hudson CLA
Modified: 2003-10-28 16:23 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 Randy Hudson CLA 2003-10-27 18:58:04 EST
GEF uses double-buffered painting.  At some point when painting to an offscreen 
Image, GDI objects (Pens in this case) are being leaked.

Let me know if you need more information or a snippet.
Comment 1 Mike Wilson CLA 2003-10-28 09:01:50 EST
Well... If you don't provide a snippet, the first thing they will do is write one. If you would rather 
they were working on the problem, it's better for you to write the snippet.
Comment 2 Steve Northover CLA 2003-10-28 09:45:24 EST
Randy, you did the research and used the MS tools as we discussed on the 
mailing list, didn't you?  I stepped through a very simple "new Shell" example 
and couldn't see the leak.

You absolutely need to provide a snippet or at least outline the steps and 
tools you used to come to this conclusion.  Otherwise, we won't be able to do 
anything and will have to close this report as WORKSFORME.  Thanks!
Comment 3 Randy Hudson CLA 2003-10-28 10:13:18 EST
Here is what I have so far:

1) Go to eclipse.org/gef and click on downloads.
2) Unzip latest (I20031028) build onto M4.  You need 2 ZIP files: runtime, and 
examples.
3) Delete the GEF and GEF.examples features, since they specify "2.1.2" of 
Eclipse
4) Launch Eclipse, File->New->Examples->GEF->Flow example.  Click Next, Finish.
5) Start selecting nodes and containers and pressing the delete key.  Delete a 
buch of stuff, undo what you deleted a few times, redo it, etc.  Handle count 
grows.

I'll see if there is a smaller scenario, but I need to prepare for a meeting at 
3:00
Comment 4 Randy Hudson CLA 2003-10-28 10:14:31 EST
To clarify, "delete features" means delete the feature folders.  They are not 
required for running GEF, just the plugins themselves are needed.
Comment 5 Randy Hudson CLA 2003-10-28 13:51:41 EST
The bug is dependent on calling GC.setLineWidth(1) on a GC created on an 
Image.  If I remove this, it goes away.
Comment 6 Randy Hudson CLA 2003-10-28 13:56:55 EST
public class Bug45640 {

public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell();
	shell.setLayout(new GridLayout());
	final Button b1 = new Button(shell, 0);
	b1.setText ("Leak some pens");
	
	b1.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			Image image = new Image(null, 100, 100);
			GC gc = new GC(image);
			gc.setLineWidth(1);
			gc.dispose();
			image.dispose();
		}
	});
	
	shell.setSize(400,300);
	shell.open();
	
	while (!shell.isDisposed())
		if (!display.readAndDispatch())
			display.sleep();
}

}
Comment 7 Silenio Quarti CLA 2003-10-28 16:11:01 EST
Foxed > 20031028.
Comment 8 Silenio Quarti CLA 2003-10-28 16:21:09 EST
The bug was only introduced in Eclipse 3.0.

It is possible to check GDI leaks with the task manager on Xp. 
Comment 9 Steve Northover CLA 2003-10-28 16:23:20 EST
Foxed?  Good thing we never shipped this.  Thanks again Randy!