Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336856 - [Compatibility] Text editors are being leaked
Summary: [Compatibility] Text editors are being leaked
Status: RESOLVED FIXED
Alias: None
Product: e4
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 1.0   Edit
Hardware: All All
: P3 critical (vote)
Target Milestone: 4.1 M6   Edit
Assignee: Remy Suen CLA
QA Contact: Paul Webster CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-10 13:13 EST by Remy Suen CLA
Modified: 2011-02-10 13:51 EST (History)
0 users

See Also:


Attachments
PopupMenuExtender patch v1 (1.08 KB, patch)
2011-02-10 13:43 EST, Remy Suen CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Suen CLA 2011-02-10 13:13:57 EST
Tried running JDT's leak tests and it seems we are leaking text editors.

junit.framework.AssertionFailedError: Expected instance count: 0, actual: 1
Element 0
org.eclipse.ui.editors.text.TextEditor
  org.eclipse.ui.texteditor.AbstractDecoratedTextEditor$1#this$0 -> org.eclipse.ui.editors.text.TextEditor@1a99c02
  java.lang.Object[0] -> org.eclipse.ui.texteditor.AbstractDecoratedTextEditor$1@7aecbb
  org.eclipse.core.runtime.ListenerList#listeners -> [Ljava.lang.Object;@14c22ed
  org.eclipse.jface.action.MenuManager#listeners -> org.eclipse.core.runtime.ListenerList@14e3ee5
  java.util.HashMap$Entry#value -> org.eclipse.jface.action.MenuManager@f76524
  java.util.HashMap$Entry[1] -> org.eclipse.e4.ui.model.application.ui.menu.impl.PopupMenuImpl@1aa3ac1 (elementId: #OverviewRulerCo
  java.util.HashMap#table -> [Ljava.util.HashMap$Entry;@1834e24
  org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer#modelToManager -> {org.eclipse.e4.ui.model.application.ui.menu.impl.MenuImpl@115c6cb (elementId: org.eclipse.jdt.ui.s
  org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer$1#this$0 -> org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer@d786ca
  org.eclipse.e4.ui.services.internal.events.UIEventHandler#eventHandler -> org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer$1@139a0dc
  org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl#service -> org.eclipse.e4.ui.services.internal.events.UIEventHandler@a8d45
  java.lang.Object[160] -> {org.osgi.service.event.EventHandler}={event.topics=[org/eclipse/e4/ui/model/ui/UILabel/*], service
  java.util.ArrayList#elementData -> [Ljava.lang.Object;@179d4fb
  org.eclipse.osgi.internal.serviceregistry.ServiceRegistry#allPublishedServices -> [{org.eclipse.osgi.framework.console.CommandProvider}={service.ranking=2147483647, service.id=2}, {
  org.eclipse.osgi.framework.internal.core.Framework#serviceRegistry -> org.eclipse.osgi.internal.serviceregistry.ServiceRegistry@1d0e43a
  org.eclipse.osgi.framework.internal.core.AbstractBundle#framework -> org.eclipse.osgi.framework.internal.core.Framework@12b116f
  org.eclipse.osgi.internal.loader.BundleLoader#bundle -> org.eclipse.jdt.ui.tests_3.7.0.qualifier [154]
  org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader#delegate -> org.eclipse.jdt.ui.tests_3.7.0.qualifier
  org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader -> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@102c93e
Comment 1 Remy Suen CLA 2011-02-10 13:43:52 EST
Created attachment 188712 [details]
PopupMenuExtender patch v1

This patch will fix the problem. We were creating a link in createModelFor(String) but it was never disconnected so the MenuManagerRenderer ended up keeping a reference to the underlying workbench part.

Paul, this gets the test to pass but I'm wondering if the unlinking should've been done automatically by some other piece of code?
Comment 2 Remy Suen CLA 2011-02-10 13:51:00 EST
(In reply to comment #1)
> Paul, this gets the test to pass but I'm wondering if the unlinking should've
> been done automatically by some other piece of code?

<rcjsuen> paulweb515: is this okay or should it have been automagic? https://bugs.eclipse.org/bugs/show_bug.cgi?id=336856#c1
<paulweb515> rcjsuen: that seems proper ... we linked them when the PopupMenuExtender was created, we need to unlink them when they go away

Released to HEAD (with a copyright header change).