From 4f6fd746027b05ad173d552f18885103c46c6d2a Mon Sep 17 00:00:00 2001 From: Philip Langer Date: Mon, 15 May 2017 13:44:12 +0200 Subject: [PATCH] [516645] Fix memory leak in EMFCompareContentMergeViewer With this change, we do the following on dispose: menuService.releaseContributions(toolBarManager); menuService.populateContributionManager(toolBarManager, "nothing"); menuService.releaseContributions(toolBarManager); The first call clears the contributions of the toolbar manager. The second populates again but with an empty toolbar manager and a location that presumably has no contributions, resulting in a still empty toolbar manager, but the important point is that it it reconciles with the current state, ensuring that all the old items are cleared. I'm not sure if this situation represents a bug in the IMenuService implementation or if EMF Compare is abusing it. Anyway, this change fixes the leak on EMF Compare side. Bug: 516645 Change-Id: I8f1b07781656e828ac8b6eca0f3f7a36be7cb0ae Signed-off-by: Philip Langer --- .../internal/contentmergeviewer/EMFCompareContentMergeViewer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/EMFCompareContentMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/EMFCompareContentMergeViewer.java index 3562ec913..eaf11bc56 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/EMFCompareContentMergeViewer.java +++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/EMFCompareContentMergeViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2016 Obeo and others. + * Copyright (c) 2012, 2017 Obeo and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,6 +9,7 @@ * Obeo - initial API and implementation * Michael Borkowski - bug 462863 * Stefan Dirix - bug 473985 + * Philip Langer - bug 516645 *******************************************************************************/ package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer; @@ -379,6 +380,9 @@ public abstract class EMFCompareContentMergeViewer extends ContentMergeViewer im toolBarManager.getControl().addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { menuService.releaseContributions(toolBarManager); + // re-populate and release menu contributions to fix memory leak (see bug 516645) + menuService.populateContributionManager(toolBarManager, "nothing"); //$NON-NLS-1$ + menuService.releaseContributions(toolBarManager); } }); } -- 2.11.4.GIT