• Post Reply Bookmark Topic Watch Topic
  • New Topic

Out of Memory / Heap full exceptions  RSS feed

 
raj yennam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We are working on a project which involves technologies like struts, JSP, hibernate.

We are facing problems like Out of memory or heap action quite frequnetly. We are trying to look at the obejcts and garbage collecting. We are also looking at clean up of session obejcts and so on.

Do you have any suggestions if anyone has this problem earlier.

Thanks,

Raj.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give your container more memory. Which one are you using?
[ September 28, 2006: Message edited by: Bear Bibeault ]
 
Eduardo Dela Rosa
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you're using Hibernate, you may want to inspect your models to see if
they're set to use proxy or make them lazy (appropriately, if not all of them).

This would prevent hitting the database outright and loading the object graphs
that you don't not actually needed and could be exhausting your JVM's memory.

HTH.
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start with a heap analysis using a tool like HAT:

https://hat.dev.java.net/

Find out which objects are using the most memory (single large objects or many smaller objects of the same type). Review the code to see why they are not getting released.

If that doesn't find the problem, run the app for a while then take two heap dumps a minute or two apart (while still exercising the app). Use hat to compare the two heap dumps and see what objects are being created.

Once you figure out what objects are on the heap you'll know better how to proceed: fixing a leak, tuning a cache, increasing the heap size, etc.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It could be that:
A.) Your app has a memory leak or.
B.) Your app just requires more memory than you're giving it.

If it's a memory leak, then giving you container more heap space will only postpone the problem. Eventually, you'll run out again; no matter how high you set it. You'll need to take Scott's approach to find out exactly where the problem is.

If, on the other hand your app just requires more ram than it's getting, increasing the heap size for the server will fix the problem. You'll see your app's memory usage climb until it gets somewhat close to capacity, garbage collection will run, and the memory usage will drop significantly. A healthy web app will cycle like this the whole time it's running. In this case Bear's approach is all you need.

What container are you using?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!