This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Now EditorRegistry.componentList() returns editors that are already closed. In particular, it contains editors that corresponds to file objects in projects that are already closed. This leads to memory leaks and incorrect behavior in clients (such as C/C++ language model), because they consider that these files are still open.
Is there any way/test/module how to reproduce? Or is it just enough to write simple test which opens editor, closes it and calls EditorRegistry.componentList()?
I don't have automated tests for this. Yes, I believe opening editor, closing it and calling EditorRegistry.componentList() is quite enough to reproduce the situation.
It seems that most memory leaks described in #140059 are caused by this issue
Integrated into 'main-golden', available in NB_Trunk_Production #344 build Changeset: http://hg.netbeans.org/main/rev/b79482bc9d6e User: Vladimir Kvashin <vkvashin@netbeans.org> Log: A workaround for #139980 (EditorRegistry.componentList() returns editors that are already closed)
First it is in editor.lib2 not openide.text. Second javadoc does not say anything about opened/closed components. Passing to editor for explanation.
The dependent issue is downgraded to P3, after I pushed a workaround: for each editor in a list returned by registry, isOpen is checked: private boolean isOpen(JEditorPane editor, FileObject fo) { DataObject dao = DataObject.find(fo); if (dao != null) { EditorCookie editorCookie = dao.getCookie(EditorCookie.class); if (editorCookie != null) { JEditorPane[] panes = editorCookie.getOpenedPanes(); return panes != null && panes.length > 0; } } } However I still believe this is a bug in EditorRegistry.
Strange, your editor possibly does not get through the conditions for closing of inactive TC - in EditorModule, search for EditorApiPackageAccessor.get().notifyClose(tc) or there's some other problem. I have added logging of ER.notifyClose(). It appears to work fine for both java and c files. You may turn it on by -J-Dorg.netbeans.api.editor.EditorRegistry.level=FINEST to see if the closed editors are being notified. Closing as worksforme please reopen if the problem persists. http://hg.netbeans.org/main/rev/9d967bbb38e9
Integrated into 'main-golden', will be available in build *200812020201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/9d967bbb38e9 User: Miloslav Metelka <mmetelka@netbeans.org> Log: #139980 - EditorRegistry.componentList() returns editors that are already closed - additional logging.
Can not reproduce any more (though when filing, it was reproduced 100%)