Click to See Complete Forum and Search --> : optimizing Tree Nodes


nanode
02-08-2001, 02:46 PM
I have an interesting problem. I have a graphical Tree (javax.swing.JTree) that contains several thousand nodes, across a few branch levels.

step 1:
This tree is created from a text file that is parsed. The text file itself is over 500K + the overhead of parsing, sorting and creating the corresponding nodes.

In the app. the user will reference this GUI tree several times, so it isn't necessary to re-read the original file and re-do everything.

step 2:
I got the idea to serialize (write object to filesystem) the root of the tree, which all other nodes are added to.

This works and is faster than the 1st method, however the serialize root node file is over 2MB!!!

Granted, reading that is still faster than reading the orig. file, because the procedures to create the tree are skipped.
(The object is simply loaded into memory).

Given that I MUST do step 1 at startup, how can I improve performance of step 2?

Would it be foolish to take up 2MB or main memory, or should I leave it slow and write to the filesystem?