wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Http post memory deallocation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Http post memory deallocation" Watch "Http post memory deallocation" New topic
Author

Http post memory deallocation

Vitor Isaia
Greenhorn

Joined: Mar 07, 2005
Posts: 12
Hello!
I have an upload application, wich consists in an applet that sends post requests to a servlet, through the Jakarta Commons HttpClient libs. The file is uploaded in packages, so I divide the file in 100 parts and send each part per httppost. So when I upload a file I do 100 posts, one per package. What happens is, for every post, the server memory (jboss 4.0.3SP1 - uses Tomcat 5) increases according to the post size. At the end of the process, the server do not deallocate that memory. So after I upload a few large files, I have an out of memory exception. I don't know how to deallocate that memory, actually should I? I think the server should know that memory is not used any more and then deallocate it. At the and of the doPost servlet's method, I placed a System.gc() but did not change anything. Any suggestions?

EDIT: I did a preview search and didn't find anything about this issue...

Thanks a lot for any help.
[ September 05, 2006: Message edited by: Vitor Isaia ]
Vitor Isaia
Greenhorn

Joined: Mar 07, 2005
Posts: 12
I call this method 100 times, one per package.


Encoder.base64Encode(pack) returns the file content in a String (base64)... So this should increase the client's memory, not server's. Every time I call this method in the client, the server's memory increase... So, just posting the content is enough to increase the server's memory... even if I don't do anything in the servlet... It is very strange... Thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
I have an out of memory exception. I don't know how to deallocate that memory, actually should I? I think the server should know that memory is not used any more and then deallocate it


The most likely explanation is that something in your server program is holding on to objects that are no longer needed. The JVM will diligently try to clean up memory before throwing a memory exception so your dont have to call gc().

How are you monitoring memory used by Tomcat?

Bill
Vitor Isaia
Greenhorn

Joined: Mar 07, 2005
Posts: 12
Yes, that is the most common case, but not mine... just beacause if I left the doPost servlet's method empty, the memory still increases. I'm suspecting the server is not supporting large posts... it doesn't make sense.
Vitor Isaia
Greenhorn

Joined: Mar 07, 2005
Posts: 12
How are you monitoring memory used by Tomcat?


I'm watching the process in Windows Task Manager... this way I'm shure the memory increase is in the server, not in the client.

The servlet do some processing with the data... it reads the bytes and converts it, writing to a temporary file... saves some information in a structure similar to the httpSession, and other stuff. BUT the thing is... if I don't call the servlet's method (leaving the doPost method EMPTY) the memory increases exactly the same way... that's what is driving me crazy...! So, the problem is in POSTING data... even without any processing by the servlet. It is very weird.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There are a couple of free ways you can see some more detail information about your memory.

1.) The Tomcat Manager application has a "Server Status" link that will show you some information:

Example.



2.) I've just started playing with the jconsole app that ships with JDK1.5.0.
Jconsole is a swing app that digs pretty deep into the JVM and shows you a lot of information. Since Tomcat has a lot of JMX support, you can use jconsole to interrogate a lot of the inner workings of Tomcat itself.


Then, of course, if you have $$$$ to spend there is JProbe or OptimizeIt.
These profilers can show you every object in your app and really help find the bottlenecks.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

http://www.onjava.com/pub/a/onjava/2004/09/29/tigerjmx.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Http post memory deallocation