Fine tuned dispose logic to avoid single item removals when whole GE is
disposed.
Node expand was causing unnecessary events, when it tried to expand
non-expandable node.
#692
Change-Id: I06938693af2b28dc51b5d2d5a0269cfde7121fc7
(cherry picked from commit
d7ce5ab37a70cf207e3bfe0045c0df3f1fb98415)
// we have to remove all references here to reduce memory consumption.
//
// Proper fix would be to remove references between QueryCache and GENodeQueryManagers.
// we have to remove all references here to reduce memory consumption.
//
// Proper fix would be to remove references between QueryCache and GENodeQueryManagers.
+
+ // Clearing explorerContext replaces GECache with dummy implementation, which makes node disposal much faster.
+ explorerContext.close();
+ // Using fastDispose bypasses item removal from nodeMap, which is cleared later.
+ rootNode.fastDispose();
- explorerContext.dispose();
+ explorerContext.dispose();
explorerContext = null;
processors.clear();
detachPrimitiveProcessors();
explorerContext = null;
processors.clear();
detachPrimitiveProcessors();
}
resourceManager.dispose();
resourceManager = null;
}
resourceManager.dispose();
resourceManager = null;
-
- contextToNodeMap.clear(); // should be empty at this point.
+ contextToNodeMap.clear();
contextToNodeMap = null;
if (postSelectionProvider != null) {
postSelectionProvider.dispose();
contextToNodeMap = null;
if (postSelectionProvider != null) {
postSelectionProvider.dispose();
+ public void close() {
+ cache.dispose();
+ cache = new DummyCache();
+ scheduleList.clear();
+ autoExpanded.clear();
+ }
+
@Override
public void dispose() {
cache.dispose();
@Override
public void dispose() {
cache.dispose();
final HashMap<GECacheKey, IGECacheEntry> entries = new HashMap<GECacheKey, IGECacheEntry>();
final HashMap<GECacheKey, Set<UIElementReference>> treeReferences = new HashMap<GECacheKey, Set<UIElementReference>>();
final HashMap<NodeContext, Set<GECacheKey>> keyRefs = new HashMap<NodeContext, Set<GECacheKey>>();
final HashMap<GECacheKey, IGECacheEntry> entries = new HashMap<GECacheKey, IGECacheEntry>();
final HashMap<GECacheKey, Set<UIElementReference>> treeReferences = new HashMap<GECacheKey, Set<UIElementReference>>();
final HashMap<NodeContext, Set<GECacheKey>> keyRefs = new HashMap<NodeContext, Set<GECacheKey>>();
+ private TObjectIntHashMap<NodeContext> references = new TObjectIntHashMap<NodeContext>();
/**
* This single instance is used for all get operations from the cache. This
/**
* This single instance is used for all get operations from the cache. This
return references.get(context) > 0;
}
return references.get(context) > 0;
}
- private TObjectIntHashMap<NodeContext> references = new TObjectIntHashMap<NodeContext>();
@Override
public void incRef(NodeContext context) {
@Override
public void incRef(NodeContext context) {
+ /**
+ * Fast dispose is used to wipe the whole tree.
+ *
+ * ContextToNodeMap is cleared with one command, so we do not need to remove nodes one by one from the map.
+ */
+ public void fastDispose() {
+ if (DEBUG) System.out.println("dispose " + this);
+ parent = null;
+ for (TreeNode n : children) {
+ n.fastDispose();
+ }
+ clearCache();
+ children.clear();
+ context = null;
+ explorerContext = null;
+ manager.dispose();
+ manager = null;
+ }
+
private void clearCache() {
if (explorerContext != null) {
GECache2 cache = explorerContext.cache;
private void clearCache() {
if (explorerContext != null) {
GECache2 cache = explorerContext.cache;
List<Integer> rowIndexes = this.treeRowModel.expand(parentIndex);
// Bug 432865: iterating and removing every single item is faster than
// removeAll()
List<Integer> rowIndexes = this.treeRowModel.expand(parentIndex);
// Bug 432865: iterating and removing every single item is faster than
// removeAll()
+ if (rowIndexes.isEmpty())
+ return;
for (final Integer expandedChildRowIndex : rowIndexes) {
this.hiddenRowIndexes.remove(expandedChildRowIndex);
}
for (final Integer expandedChildRowIndex : rowIndexes) {
this.hiddenRowIndexes.remove(expandedChildRowIndex);
}