aspose file tools*
The moose likes Tomcat and the fly likes Out of memory in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Out of memory in Tomcat" Watch "Out of memory in Tomcat" New topic
Author

Out of memory in Tomcat

Anjana Ravindran
Ranch Hand

Joined: Aug 22, 2005
Posts: 76
I have few applications running in my tomcat. I am getting "out of memory" issues. To solve this, java heap size is increased and tomcat is bounced often.

Please give me pointers on handling this issue in a right way. How could i find the memory problem and solve it? What tool can be used? What tweaks i can do to find the problem. Any pointers would be helpful.
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Please give me pointers on handling this issue in a right way. How could i find the memory problem and solve it? What tool can be used? What tweaks i can do to find the problem. Any pointers would be helpful.


You run out of memory if you just create too many objects and save the references, if the object you are creating is too large to handle, some I/O is being done which consumes too much of resources and may other cases.

XMX and XMS parameters to the JVM set how much memory to give to JVM. But, simply giving yourself more won't fix the problem, if you keep creating too many objects - you can still run out of memory eventually.

Well, I don't think there is a specific tool for finding such issue. You just have to check if your code is well as per performance constraints.
A few guidelines can be :
- Checking if all I/Os are opened & closed properly
- DB connections and sessions are handled effectively
- Some loop which undesiredly is creating larger number of objects
- Too many refrences without bothering to clean them.

Simple word is to optimize. In this process you basically need to find which code segment makes that problem often and then hit that part.
Arvind Mishra
Greenhorn

Joined: Jul 04, 2007
Posts: 28
Hi

Add this variable in Env Variables

Variable Name : JAVA_OPTS
Value : -Xms1024m -Xmx1024m -XX:MaxPermSize=128m

You can change the memory settings according to memory avaalable in your machine


Regards<br />Arvind Mishra<br />SCJP<br />SCWCD<br />IBM SOA Associate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Out of memory in Tomcat