Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Http post memory deallocation

 
Vitor Isaia
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic