Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-05-16 04:59:12 -0400
committerUwe Stieber2014-05-16 04:59:12 -0400
commit745a0b0bba3a1d89283d25ca635e890b09943d7f (patch)
treea1aca1f555f637743d15bd0ce37bca37bbde2dc0
parent3d4e340abdaf178eebe5e25f0b44b5e583ab75e0 (diff)
downloadorg.eclipse.tcf-745a0b0bba3a1d89283d25ca635e890b09943d7f.tar.gz
org.eclipse.tcf-745a0b0bba3a1d89283d25ca635e890b09943d7f.tar.xz
org.eclipse.tcf-745a0b0bba3a1d89283d25ca635e890b09943d7f.zip
Target Explorer: Improve memory consumption for frequently called messages
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/utils/DataHelper.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java40
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEventListener.java2
3 files changed, 31 insertions, 33 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/utils/DataHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/utils/DataHelper.java
index e8ad5d3c7..52f9b4c78 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/utils/DataHelper.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/utils/DataHelper.java
@@ -12,6 +12,7 @@ package org.eclipse.tcf.te.runtime.persistence.utils;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -42,6 +43,8 @@ public class DataHelper {
return null;
}
+ private static final Map<String, IPropertiesContainer> cache = new LinkedHashMap<String, IPropertiesContainer>();
+
/**
* Decode a string encoded properties container.
* @param encoded The string encoded properties container.
@@ -49,12 +52,21 @@ public class DataHelper {
*/
public static final IPropertiesContainer decodePropertiesContainer(String encoded) {
if (encoded != null && encoded.trim().length() > 0) {
- try {
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(Map.class, String.class);
- return (IPropertiesContainer)delegate.read(IPropertiesContainer.class, encoded);
- }
- catch (Exception e) {
+ IPropertiesContainer result = cache.remove(encoded);
+ if (result == null) {
+ try {
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(Map.class, String.class);
+ result = (IPropertiesContainer)delegate.read(IPropertiesContainer.class, encoded);
+ }
+ catch (Exception e) {
+ }
+
+ if (cache.size() == 10) cache.remove(cache.keySet().toArray()[0]);
}
+
+ cache.put(encoded, result);
+
+ return result;
}
return new PropertiesContainer();
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java
index e7278e68e..a0aff7836 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java
@@ -61,7 +61,6 @@ public class PeerNode extends ContainerModelNode implements IPeerNode, IPeerNode
private String peerId;
private boolean isValid = true;
- private boolean recomputeValidState = true;
/**
* Constructor.
@@ -150,30 +149,23 @@ public class PeerNode extends ContainerModelNode implements IPeerNode, IPeerNode
*/
@Override
public boolean isValid() {
- // Due to bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=385394, isValid() is called again
- // and again around every 400 ms. Don't recompute the valid status if no property has changed.
- // We may remove this once the minimum required Eclipse version is 4.4M5.
- if (recomputeValidState) {
- recomputeValidState = false;
-
- final AtomicBoolean valid = new AtomicBoolean(true);
- IService[] services = ServiceManager.getInstance().getServices(this, IDelegateService.class, false);
- for (IService service : services) {
- if (service instanceof IDelegateService) {
- IPeerNode.IDelegate delegate = ((IDelegateService)service).getDelegate(this, IPeerNode.IDelegate.class);
- if (delegate != null) {
- if (delegate.isVisible(this) && !delegate.isValid(this)) {
- valid.set(false);
- break;
- }
+ final AtomicBoolean valid = new AtomicBoolean(true);
+ IService[] services = ServiceManager.getInstance().getServices(this, IDelegateService.class, false);
+ for (IService service : services) {
+ if (service instanceof IDelegateService) {
+ IPeerNode.IDelegate delegate = ((IDelegateService)service).getDelegate(this, IPeerNode.IDelegate.class);
+ if (delegate != null) {
+ if (delegate.isVisible(this) && !delegate.isValid(this)) {
+ valid.set(false);
+ break;
}
}
}
+ }
- if (isValid != valid.get()) {
- isValid = valid.get();
- fireChangeEvent(IPeerNodeProperties.PROP_VALID, new Boolean(isValid), new Boolean(valid.get()));
- }
+ if (isValid != valid.get()) {
+ isValid = valid.get();
+ fireChangeEvent(IPeerNodeProperties.PROP_VALID, new Boolean(isValid), new Boolean(valid.get()));
}
return isValid;
@@ -290,9 +282,6 @@ public class PeerNode extends ContainerModelNode implements IPeerNode, IPeerNode
peerId = getPeer().getID();
Assert.isNotNull(peerId);
- // Properties changed -> recompute valid state
- recomputeValidState = true;
-
super.postSetProperties(properties);
}
@@ -311,9 +300,6 @@ public class PeerNode extends ContainerModelNode implements IPeerNode, IPeerNode
Assert.isNotNull(peerId);
}
- // Properties changed -> recompute valid state
- recomputeValidState = true;
-
super.postSetProperty(key, value, oldValue);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEventListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEventListener.java
index 395ede63a..ea4d41dea 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEventListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEventListener.java
@@ -76,7 +76,7 @@ public class ProcessMonitorEventListener extends AbstractEventListener {
else if (source instanceof IPeerNode && source == getPeerNode()) {
if (IPeerNodeProperties.PROP_CONNECT_STATE.equals(changeEvent.getEventId())) {
// Peer node connect state changed to connected
- if (changeEvent.getNewValue().equals(new Integer(IConnectable.STATE_CONNECTED))) {
+ if (changeEvent.getNewValue().equals(Integer.valueOf(IConnectable.STATE_CONNECTED))) {
// Get the new runtime model
final IRuntimeModel model = ModelManager.getRuntimeModel(getPeerNode());
// Update the tree viewer input element

Back to the top