Resources leaking in OutlineView

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Resources leaking in OutlineView

Dmitry Avtonomov
​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 ...

// run node expansion
Runnable runNodeExpansion = new Runnable() {
    public void run() {
        Node toExpand = root;
        Node prevNode = toExpand;
        boolean foundChildren, nodesEqual;
        do {
            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);

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?

Dmitry Avtonomov