Resources leaking in OutlineView
Dmitry Avtonomov <[email protected]> Tue, 30 May 2017 03:13:54 -0400
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <CAMMjtf82c9bacHqYJLQSPOrdYNW8xsaxvyruR3WhGxRQSGU4VA@mail.gmail.com> |
Hi all,
I'm trying to automatically expand my OutlineView right after creation:
// create the components
ExplorerManager em = new ExplorerManager();
OutlineView ov = new OutlineView();
Node root = new ...
em.setRootContext(root);
// run node expansion
Runnable runNodeExpansion = new Runnable() {
@Override
public void run() {
Node toExpand = root;
Node prevNode = toExpand;
boolean foundChildren, nodesEqual;
do {
//ov.expandNode(toExpand);
Node[] nodes = toExpand.getChildren().getNodes(true);
foundChildren = false;
nodesEqual = false;
if (nodes != null && nodes.length > 0) {
toExpand = nodes[0];
foundChildren = true;
nodesEqual = toExpand.equals(prevNode);
prevNode = toExpand;
}
} while (foundChildren && !nodesEqual);
ov.expandNode(toExpand);
}
};
SwingUtilities.invokeLater(runNodeExpansion);
If I don't run the expansion code - everything works. As soon as the
expansion code is run within the constructor of my top component the
expansion itself works - it drills down along the first child nodes till it
finds a node with no children and expands that path. But any navigation
around the tree (e.g. pressing arrow keys on keyboard) triggers
uncontrolled CPU usage and memory usage grows quickly to gigabytes. It
seems like calling Node#getChildren()#getNodes() is causing some problems,
but I'm not sure. Is there something obviously wrong with the above code?
Regards,
Dmitry Avtonomov