Hi, I have made a servlet that recurively goes down the folder structure of a CMS and adds up the total size of each folder coming up using LRN traversal.
For a huge number of folders(about 2500) my JVM heap just blows up like crazy and the whole traversal is really really slow.
Any ideas how I can make the output generation faster and use much less heap memory. I cannot print part of the tree first since the size of the top level folder cannot be determined until the whole traversal is complete.
What are you keeping in memory during this procedure? If you just print info and move on then i wouldn't think the size of the directory structures or number of them would make you run out of memory. Can you give a sample printout of what you are trying to do?
I think it is a mistake to try to put EVERYTHING in one HTML page. When I have done this sort of thing it starts with a simple presentation of the first level of directories. The user can expand one directory at a time with a request that redraws the tree.
Seriously - is any user every going to want the whole tree or are they just looking for one directory. A clear "use case" for what the user really needs is your friend at this stage of design.
You could use an AJAX style app so that much of the page stays intact with parts redrawn with each click.
There only thing that needs to stay in server memory is a few File objects representing the directory nodes of the current display.