Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2023-03-13 15:33:08 +0000
committerVincent Lorenzo2023-03-20 11:39:10 +0000
commit47561ecdbb0acf3371bee37e16c72b6c8325bef7 (patch)
tree3b39186eb4fa8e247e09fd7d4ea56249d820b142 /plugins/infra
parent1911633809366a2c78c3f6522c0851334884e1cf (diff)
downloadorg.eclipse.papyrus-47561ecdbb0acf3371bee37e16c72b6c8325bef7.tar.gz
org.eclipse.papyrus-47561ecdbb0acf3371bee37e16c72b6c8325bef7.tar.xz
org.eclipse.papyrus-47561ecdbb0acf3371bee37e16c72b6c8325bef7.zip
Bug 581660: [MemoryLeak] Several memory leak detected with Graal Visual VM
-in org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.MultiPageEditorSite, we complete the dispose(): - remove reference to the current editor - remove selection and postSelection listener on the selectionProvider -> it allwos to remove all instance of nested classes MultiPageEditorSite$1 and MultiPageEditorSite$2 in VisualVM Change-Id: I880886e75bea194fcde5411edb2e54a0dff30983 Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java
index cf1db769afc..e638a5c5def 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/eclipsecopy/MultiPageEditorSite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation, Christian W. Damus, and others.
+ * Copyright (c) 2000, 2015, 2023 IBM Corporation, Christian W. Damus, and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,10 +10,12 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Christian W. Damus - bug 403755
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - bug 581660
*******************************************************************************/
package org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy;
import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.e4.core.contexts.ContextFunction;
@@ -87,7 +89,7 @@ public class MultiPageEditorSite implements IMultiPageEditorSite, INestable {
/**
* The list of popup menu extenders; <code>null</code> if none registered.
*/
- private ArrayList menuExtenders;
+ private List<PopupMenuExtender> menuExtenders;
/**
* The main editor EditorSite.
@@ -302,7 +304,7 @@ public class MultiPageEditorSite implements IMultiPageEditorSite, INestable {
public void dispose() {
if (menuExtenders != null) {
for (int i = 0; i < menuExtenders.size(); i++) {
- ((PopupMenuExtender) menuExtenders.get(i)).dispose();
+ menuExtenders.get(i).dispose();
}
menuExtenders = null;
}
@@ -335,6 +337,16 @@ public class MultiPageEditorSite implements IMultiPageEditorSite, INestable {
contextFunction.dispose();
contextFunction = null;
+
+ this.selectionProvider.removeSelectionChangedListener(getSelectionChangedListener());
+ if (selectionProvider instanceof IPostSelectionProvider) {
+ ((IPostSelectionProvider) selectionProvider).removePostSelectionChangedListener(getPostSelectionChangedListener());
+ } else {
+ selectionProvider.removeSelectionChangedListener(getPostSelectionChangedListener());
+ }
+ this.postSelectionChangedListener = null;
+ this.selectionChangedListener = null;
+ this.editor = null;
}
/**
@@ -634,7 +646,7 @@ public class MultiPageEditorSite implements IMultiPageEditorSite, INestable {
@Override
public void registerContextMenu(String menuID, MenuManager menuMgr, ISelectionProvider selProvider) {
if (menuExtenders == null) {
- menuExtenders = new ArrayList(1);
+ menuExtenders = new ArrayList<>(1);
}
PartSite.registerContextMenu(menuID, menuMgr, selProvider, true, editor, context, menuExtenders);
}
@@ -642,7 +654,7 @@ public class MultiPageEditorSite implements IMultiPageEditorSite, INestable {
@Override
public final void registerContextMenu(final String menuId, final MenuManager menuManager, final ISelectionProvider selectionProvider, final boolean includeEditorInput) {
if (menuExtenders == null) {
- menuExtenders = new ArrayList(1);
+ menuExtenders = new ArrayList<>(1);
}
PartSite.registerContextMenu(menuId, menuManager, selectionProvider, includeEditorInput, editor, context, menuExtenders);
}

Back to the top