• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to catch OutOfMemoryError  RSS feed

 
malla kiran
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of late we are gettig this error on our site... we are using Jsp and java beans... The scenario is like .... we have called 3-4 methods in jsp page.. Currently it has thrown this exception after executing 2 methods... All the methods are in try catch bolcks...
Is there any method to catch this type of exception...
Waiting for an early reply....
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two things that you could do are (1) configure the amount of memory for your web/application server and (2) get a profiling tool such as JProbe or OptimizeIt to check where you are losing the memory. I would start by checking how much heap memory is being assigned on server startup.
Catching OutOfMemoryExceptions isn't generally very useful, particularly if you are running within a managed container environment.
BTW, can you take a look at the naming policy and edit your profile accordingly.
Cheers
Simon
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your servlets or JSP pages have any problems and you see "java.lang.OutOfMemoryError" in your log files or in a stack trace generated by the JVM, then you probably need to increase the JVM's maximum heap size.
Each instance of a Java Virtual Machine uses an allocation of memory for all objects, shared among all its threads, called the heap. The default size and some of the features of the heap's behavior are implementation dependent, but most (if not all) implementations allow you to modify the heap's minimum and maximum size, and most provide a default value for these settings.
What setting you choose should be determined by testing and trial and error. It is highly application and load dependent.
You should not try to catch OutOfMemoryErrors in your application. They are not generally predictable. And when they do happen, there's nothing to be done to recover, because by then the JVM is out of memory and the garbage collector is unable to free any memory for further work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!