This question is about a Java JTree or a Window .Net Tree (Winforms) or an Adobe Flex Tree.
In a client-server application (for Flex it's Web, really), I have a tree with hierarchical data (in a Windows Explorer type interface). Right now I lazily load up the tree as the user requests more data from the server. This is fine and will work up to about 750K nodes (empirically tested on .Net Winforms and Adobe Flex), but after that it gets sluggish. But the databases grow fast (mostly because users can paste in huge amounts of nodes) and a database of 20 million nodes is not at all unlikely.
Should I be releasing data from the tree when a branch is collapsed so the Garbage Collector can release the memory? This is fine, but what if the users are not efficient and don't collapse branches? Should I do a memory management module that goes around closing branches that haven't been touched in a while?
This all seems like a lot of work so as not to not run out of memory.
Edit: Should I release data on node collapse? If so, when? The weak-object cache idea is good, but should I just continue filling up the UI until it busts (maybe it's not a bad idea)?