Bug 119917 - [implementation] AbstractControlContentAssistSubjectAdapter - leaks Regions
Summary: [implementation] AbstractControlContentAssistSubjectAdapter - leaks Regions
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 3.1.2   Edit
Assignee: Dani Megert CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-08 12:32 EST by Susan McCourt CLA Friend
Modified: 2006-01-10 05:53 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Susan McCourt CLA Friend 2005-12-08 12:32:00 EST
I've been adapting the hover code in AbstractControlContentAssistSubjectAdapter for use in the JFace task assistance work (bug #106199).  It appears that a new region is created each time the hover text is set, but the old region is never disposed, and the last region is not disposed when the shell is disposed.
Comment 1 Dani Megert CLA Friend 2005-12-08 12:34:54 EST
What scenario?
Can you attach the object graph?
Comment 2 Susan McCourt CLA Friend 2005-12-08 14:23:53 EST
I just saw this when inspecting the code, I didn't observe it with any tests.
It would happen each time the text is set into an already created hover.
In my adaptation this happens quite a bit because I reuse the same hover for different field decorations.  In your use, it may be that the text rarely is changed, but the code leaves you open to the leak.

The code in question is in Hover

			void setText(String t) {
				if (t == null)
					t= ""; //$NON-NLS-1$
				if (! t.equals(fText)) {
					Point oldSize= getExtent();
					fText= t;
					fHoverShell.redraw();
					Point newSize= getExtent();
					if (!oldSize.equals(newSize)) {
						Region region= new Region();
						region.add(getPolygon(false));
						fHoverShell.setRegion(region);
					}
				}
			}


My code does this (can't easily attach a patch as I've altered the code quite a bit):

		/*
		 * Compute a new shape for the hover shell.
		 */
		void setNewShape() {
			Region oldRegion = region;
			region = new Region();
			region.add(getPolygon(false));
			hoverShell.setRegion(region);
			if (oldRegion != null) {
				oldRegion.dispose();
			}

		}


and...


		void dispose() {
			if (!hoverShell.isDisposed())
				hoverShell.dispose();
			if (region != null) {
				region.dispose();
			}
		}




Comment 3 Dani Megert CLA Friend 2005-12-09 02:31:53 EST
Good catch!
Comment 4 Dani Megert CLA Friend 2005-12-09 03:02:27 EST
The resource leak happens with every usage of the SmartFieldController.
Fixed in HEAD.
Available in builds > N20051209-0010.

Approving to fix in 3.2.1.
Comment 5 Dani Megert CLA Friend 2005-12-09 04:54:51 EST
Fix released into R3_1_maintenance.
Comment 6 Markus Keller CLA Friend 2006-01-10 05:53:01 EST
Verified by code inspection in M20060109-1200.