File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Performance and the fly likes Servlet using too much heap space Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Servlet using too much heap space" Watch "Servlet using too much heap space" New topic
Author

Servlet using too much heap space

rehan shah
Greenhorn

Joined: Jan 29, 2008
Posts: 1
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

Joined: Jun 26, 2002
Posts: 861
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?


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet using too much heap space