aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2011-09-23 15:33:34 (EDT)
committerOleg Besedin2011-09-23 15:33:34 (EDT)
commitca5404eb7ab1e116df0736da131764508e97e533 (patch)
tree1bc394955385a887c32039492253524f5212995c
parent00fab0d4daa0dd4c59a435f7a0f4afe02fcae76c (diff)
downloadeclipse.platform.runtime-ca5404eb7ab1e116df0736da131764508e97e533.zip
eclipse.platform.runtime-ca5404eb7ab1e116df0736da131764508e97e533.tar.gz
eclipse.platform.runtime-ca5404eb7ab1e116df0736da131764508e97e533.tar.bz2
Bug 358658 - Roughly 40% of the heap being eaten by EclipseContextsv20110923-1933
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java
index 3212c8e..05a5113 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java
@@ -115,7 +115,7 @@ public class EclipseContext implements IEclipseContext {
}
}
- private Map<String, HashSet<ComputationReference>> listeners = Collections.synchronizedMap(new HashMap<String, HashSet<ComputationReference>>());
+ private Map<String, HashSet<ComputationReference>> listeners = Collections.synchronizedMap(new HashMap<String, HashSet<ComputationReference>>(10, 0.8f));
private Map<String, ValueComputation> localValueComputations = Collections.synchronizedMap(new HashMap<String, ValueComputation>());
private Set<Computation> activeRATs = new HashSet<Computation>();
@@ -324,9 +324,12 @@ public class EclipseContext implements IEclipseContext {
else
invalidListenersCount++;
}
- // more than half of listeners are invalid, clean the listener list
- if ((invalidListenersCount << 2) > namedComputations.size()) {
- HashSet<ComputationReference> tmp = new HashSet<ComputationReference>(namedComputations.size() - invalidListenersCount);
+ if (invalidListenersCount == namedComputations.size()) {
+ // all the listeners are invalid for this name
+ listeners.remove(name);
+ } else if (invalidListenersCount > 10 && (invalidListenersCount << 1) > namedComputations.size()) {
+ // more than half of listeners are invalid, clean the listener list
+ HashSet<ComputationReference> tmp = new HashSet<ComputationReference>(namedComputations.size() - invalidListenersCount, 0.75f);
for (ComputationReference listenerRef : namedComputations) {
Computation listener = listenerRef.get();
if (listener != null && listener.isValid())
@@ -454,7 +457,7 @@ public class EclipseContext implements IEclipseContext {
public void addDependency(String name, Computation computation) {
HashSet<ComputationReference> nameListeners = listeners.get(name);
if (nameListeners == null) {
- nameListeners = new HashSet<ComputationReference>();
+ nameListeners = new HashSet<ComputationReference>(30, 0.75f);
listeners.put(name, nameListeners);
}
nameListeners.add(new ComputationReference(computation));