Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcdumoulin2012-02-15 18:25:59 -0500
committercdumoulin2012-02-15 18:25:59 -0500
commitd251d310c55810c2e2e6ddc61ef6e90c116a410d (patch)
tree9f3309d8566526c4bc418e849b045680a27d930c /plugins
parent645abd3a3a2abbfa3460d3ef47ef8e793402822e (diff)
downloadorg.eclipse.papyrus-d251d310c55810c2e2e6ddc61ef6e90c116a410d.tar.gz
org.eclipse.papyrus-d251d310c55810c2e2e6ddc61ef6e90c116a410d.tar.xz
org.eclipse.papyrus-d251d310c55810c2e2e6ddc61ef6e90c116a410d.zip
ASSIGNED - bug 366943: [Performance] Editors Memory leaks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=366943 - improve disposal of ServicesRegistry and nullify ref on serviceInstances - avoid double call on ModelSet.unload() - improve disposal of SaveAndDirtyService, LifeCycleEventsProvider - call dispose() on TransactionalEditingDomain (from ModelSet.dispose() )
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java9
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProvider.java6
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/SaveAndDirtyService.java28
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java7
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java9
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java1
6 files changed, 53 insertions, 7 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
index 8a8e764c540..47b487346cb 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
@@ -38,7 +38,6 @@ import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer;
import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
-import org.eclipse.gmf.runtime.emf.commands.core.command.EditingDomainUndoContext;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.ILabelProvider;
@@ -611,9 +610,11 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
}
// Avoid memory leak
- if(resourceSet != null) {
- resourceSet.unload();
- }
+ // This call is done from the ServicesRegistry when it is disposed.
+ // Don't need to do it there.
+// if(resourceSet != null) {
+// resourceSet.unload();
+// }
// dispose available service
if(servicesRegistry != null) {
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProvider.java
index efca7f9d6f4..1c14cbd698b 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProvider.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/LifeCycleEventsProvider.java
@@ -225,6 +225,12 @@ public class LifeCycleEventsProvider implements ILifeCycleEventsProvider {
return listeners;
}
+ /**
+ * Remove all listeners.
+ */
+ protected void clear() {
+ listeners.clear();
+ }
}
/**
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/SaveAndDirtyService.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/SaveAndDirtyService.java
index 0baf6e32d93..0006408ff7c 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/SaveAndDirtyService.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/lifecycleevents/SaveAndDirtyService.java
@@ -28,6 +28,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.common.command.CommandStackListener;
import org.eclipse.emf.transaction.NotificationFilter;
import org.eclipse.emf.transaction.ResourceSetChangeEvent;
@@ -95,7 +96,7 @@ public class SaveAndDirtyService extends LifeCycleEventsProvider implements ISav
/**
* The serviceRegistry.
*/
- private ServicesRegistry servicesRegistry;
+// private ServicesRegistry servicesRegistry;
/**
* Associated editor. Needed by saveAs to synchronize editor input.
@@ -177,7 +178,7 @@ public class SaveAndDirtyService extends LifeCycleEventsProvider implements ISav
*/
public void init(ServicesRegistry servicesRegistry) throws ServiceException {
- this.servicesRegistry = servicesRegistry;
+// this.servicesRegistry = servicesRegistry;
// Retrieve required services.
resourceSet = servicesRegistry.getService(ModelSet.class);
@@ -217,9 +218,30 @@ public class SaveAndDirtyService extends LifeCycleEventsProvider implements ISav
*/
public void disposeService() throws ServiceException {
if(transactionalEditingDomain != null) {
- transactionalEditingDomain.getCommandStack().removeCommandStackListener(commandStackListener);
+ // Check if commandStack is null (meaning that transactionalEditingDomain
+ // is disposed
+ CommandStack commandStack = transactionalEditingDomain.getCommandStack();
+ if( commandStack != null) {
+ transactionalEditingDomain.getCommandStack().removeCommandStackListener(commandStackListener);
+ }
transactionalEditingDomain.removeResourceSetListener(resourceSetListener);
+// resourceSetListener = null;
}
+
+ // clean properties in order to help GC
+ inputChangedListeners.clear();
+ inputChangedListeners = null;
+ multiDiagramEditor = null;
+// servicesRegistry = null;
+ transactionalEditingDomain = null;
+ resourceSet = null;
+ lifeCycleEvent = null;
+
+ postSaveListeners.clear();
+ saveListeners.clear();
+ preSaveListeners.clear();
+
+
}
/**
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java
index 646fb5df22e..d15bce5ce2f 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java
@@ -441,6 +441,13 @@ public class ModelSet extends ResourceSetImpl {
iter.next().unload();
iter.remove();
}
+
+ // Dispose Editing Domain
+ transactionalEditingDomain.dispose();
+ // Detach associated factories
+ adapterFactories.clear();
+ eAdapters().clear();
+
}
/**
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
index c95c9c5fceb..d281bf26609 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
@@ -827,6 +827,14 @@ public class ServicesRegistry {
disposeServices(namedServices.values(), errors);
disposeServices(anonymousServices, errors);
+ // Clean up properties to help GC
+ addedServices.clear();
+ addedServices = null;
+ anonymousServices.clear();
+ anonymousServices = null;
+ namedServices.clear();
+ namedServices = null;
+
// Report errors if any
if(errors.getExceptions().size() > 0)
throw errors;
@@ -944,6 +952,7 @@ public class ServicesRegistry {
/**
* Dispose all started services.
+ * Services are disposed in creation reverse order
*
* @throws ServiceMultiException
*
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java
index fa1ad0f8d76..c053b0f3668 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java
@@ -168,6 +168,7 @@ public class ServiceFactoryEntry extends ServiceTypeEntry {
factoryInstance.disposeService();
factoryInstance = null;
+ serviceInstance = null;
setState(ServiceState.disposed);
}

Back to the top