• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet using too much heap space

 
rehan shah
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

At every folder node I print the name, total size and a little bit of javascript/html (using out.println(...)) that enables the output to be a drill down tree folder structure.

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.

I beleive the strings for all the javascript that i need to output take too much memory...any ideas?
[ March 03, 2008: Message edited by: rehan shah ]
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic