• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Out of memory in Tomcat

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic