@Override public void actionPerformed(AnActionEvent e) { old = new TreeSet<Pair<Object, Integer>>(top); top.clear(); ObjectTree<Disposable> tree = Disposer.getTree(); Set<Disposable> roots = tree.getRootObjects(); for (Disposable root : roots) { checkDisposables(tree, root, top, LIMIT); } System.out.println("Top " + LIMIT + " disposables"); for (Pair<Object, Integer> pair : top) { System.out.println(pair.first.getClass().getName() + " (" + pair.second + " related)" + getChange(old, pair.first, pair.second)); } }
private void checkDisposables(ObjectTree tree, Object key, Set<Pair<Object, Integer>> top, int limit) { ObjectNode node = tree.getNode(key); if (node == null) { return; } Collection children = node.getChildren(); top.add(Pair.create(key, children.size())); trimToLimit(top, limit); for (Object child : children) { checkDisposables(tree, child, top, limit); } }
@NotNull public static ObjectTree<Disposable> getTree() { return ourTree; }
@Nonnull public static ObjectTree<Disposable> getTree() { return ourTree; }