• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

how to catch OutOfMemoryError

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic