Community
Participate
Eclipse IDE
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.
What scenario? Can you attach the object graph?
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(); } }
Good catch!
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.
Fix released into R3_1_maintenance.
Verified by code inspection in M20060109-1200.