Community
Participate
Working Groups
I200403240800 After opening/using ~6 editors and then closing all, I found WorkbenchPage#lastActiveEditor referencing an editor.
requires File -> Close All to reproduce.
This bug has been added to list to stop ship for M8.
fixed in head (no really :) some very ancient code in WorkbenchPage has methods closeEditor and closeEditors, which it seems over time have diverged more than you might expect. i have rewritten these methods to use a common code path. NOW: open editors A and B. close individually. no leak. reopen both editors. close all. no leak. (using yourkit 2.0.1 to check for roots of CompilationUnitEditor)
kim: please review this change for me. (the code was pretty ugly in there previously). the change is local to WorkbenchPage. thanks.
in closeEditors2(IEditorReference[]) you have the following: editorParts[i] = editorReferences[i].getEditor(false); later you call closeEditors2(IEditorPart[]). In here you do not check for the possiblity of a null editor part. This will cause the certifyPart call to fail and the entire list won't be cloesd. If you open a workspace that has open editors and try to close all immediately, you'll see it doesn't work. It's for this reason... when you getEditor(false) on an editor that is not yet visible you'll get a null part.
good catch. please retry with new changes..
also, i retested leaks in both close and close all cases with latest change.
Two test failures on I200403252030. This seems to have gotten worse. :(
I've backed out of the changes to WorkbenchPage.closeEditor* since they were causing the NPE in bug 56287 and also a test failure in IWorkbenchPageTests.closeEditorTests: bug 56284. I've made a more surgical fix for the leak. In WorkbenchPage.closeEditors, I removed the else in: if (part == activePart) { deactivated = true; setActivePart(null); } else if (lastActiveEditor == part) { lastActiveEditor = null; actionSwitcher.updateTopEditor(null); } This is in the midnight build.
Verified with YourKit 2.1 on Win2K that this fixes the leak for both plain text editors and Java editors, using both Close and Close All. Closing.