Community
Participate
Working Groups
Not a growing leak, but after editor is closed, the TextEditorPlugin still has the LastEditPosition, which has a Selection instance, which has the Document instance. Depending on what the Document is holding on to, this can leave a lot in memory unnecessarily. One fix is to simply call during dispose TextEditorPlugin.getDefault().setLastEditPosition(null); if in fact the editor set it (it appears all users of getLastEditPosition are prepared for it to be null). Note: this bug was discovered with a profiler using 2.1.1. Since its relatively minor, I'm suggesting it be fixed only with verion 3.0. Since the proposed fix is so small, I've included the patch output here: Index: AbstractTextEditor.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench. texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java,v retrieving revision 1.65 diff -u -r1.65 AbstractTextEditor.java --- AbstractTextEditor.java 7 Jul 2003 21:21:33 -0000 1.65 +++ AbstractTextEditor.java 14 Jul 2003 04:21:49 -0000 @@ -385,7 +385,10 @@ // pos is null } } + // note: during dispose the LastEditPosition is set to null, + // so the TextEditorPlugin does not "hold on to" the Document in Selection TextEditorPlugin.getDefault().setLastEditPosition(new EditPosition(input, getEditorSite().getId(), getSelectionProvider(). getSelection(), pos)); + fLastEditPositionAdded = true; } } } @@ -1447,6 +1450,13 @@ * @since 2.1 */ private String[] fKeyBindingScopes; + /** + * Remember if this instance set the last edit + * position, so it can be set to null during + * dispose, if it did set it. + * @since 3.0 + */ + private boolean fLastEditPositionAdded; /** * The editor's insert mode. * @since 3.0 @@ -2648,6 +2658,14 @@ if (fEditorStatusLine != null) fEditorStatusLine= null; + + if (fLastEditPositionAdded) { + // in case last edit position was set, which might + // be holding on to Selectin (which hold on to Document). + // And, we don't want to set to null, unless we + // were the ones to set it. + TextEditorPlugin.getDefault().setLastEditPosition(null); + } super.setInput(null);
Fixed in HEAD: got rid of selection. The patch would have disabled Go To Last Edit Position feature once the editor got closed.