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

Out of memory in Tomcat

 
Anjana Ravindran
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic