Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-05-02 13:07:55 +0000
committerChristian W. Damus2014-05-02 13:09:10 +0000
commitdb038d1db6955f448b9ea8deaa3f8c1182178ae3 (patch)
tree43414341fccb3858e5aae2132a3988f2871f9d27 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src
parente4c0e2b0fae57d8cdd0207cdb08497be712d63e2 (diff)
downloadorg.eclipse.papyrus-db038d1db6955f448b9ea8deaa3f8c1182178ae3.tar.gz
org.eclipse.papyrus-db038d1db6955f448b9ea8deaa3f8c1182178ae3.tar.xz
org.eclipse.papyrus-db038d1db6955f448b9ea8deaa3f8c1182178ae3.zip
422257: [Performances] Memory leaks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=422257 Ensure that resource sets used to manipulate UML models in wizards are properly cleaned up to avoid leaking in the CacheAdapter.
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/MultiDiagramUtil.java32
1 files changed, 20 insertions, 12 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/MultiDiagramUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/MultiDiagramUtil.java
index e8e1925cf1e..f67c9265ab8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/MultiDiagramUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/util/MultiDiagramUtil.java
@@ -1,12 +1,13 @@
/*******************************************************************************
* Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, Generalitat
- * de la Comunitat Valenciana . All rights reserved. This program
+ * de la Comunitat Valenciana, CEA, 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 http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Francisco Javier Cano Muñoz (Prodevelop) – Initial implementation.
* Gabriel Merin Cubero (Prodevelop) – Added version to diagrams
+ * Christian W. Damus (CEA) - bug 422257
*
******************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.util;
@@ -50,6 +51,7 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.ids.MOSKittEditorIDs;
import org.eclipse.papyrus.uml.diagram.common.part.CachedResourcesDiagramEditor;
@@ -856,19 +858,25 @@ public class MultiDiagramUtil {
// @unused
public static boolean deleteAndSaveEObjectInResource(URI uri, String fragment) {
URI resourceURI = uri;
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
- Resource resource = resourceSet.getResource(resourceURI, true);
- EObject toDelete = resource.getEObject(fragment);
- if(toDelete != null && resource.getContents().contains(toDelete)) {
- resource.getContents().remove(toDelete);
- try {
- resource.save(getSaveOptions());
- } catch (IOException e) {
- Log.error(null, 0, "Error saving resource " + resource.toString(), e);
- return false;
+ final ResourceSet resourceSet = new ResourceSetImpl();
+
+ try {
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
+ Resource resource = resourceSet.getResource(resourceURI, true);
+ EObject toDelete = resource.getEObject(fragment);
+ if(toDelete != null && resource.getContents().contains(toDelete)) {
+ resource.getContents().remove(toDelete);
+ try {
+ resource.save(getSaveOptions());
+ } catch (IOException e) {
+ Log.error(null, 0, "Error saving resource " + resource.toString(), e);
+ return false;
+ }
}
+ } finally {
+ EMFHelper.unload(resourceSet);
}
+
return true;
}

Back to the top