• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

catching java.lang.OutofMemoryException ?

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
catching java.lang.OutofMemoryException ?
We 'll find that it's almost never feasible to really catch it. By the time it's thrown, it's
likely that the situation is beyond repair and your JVM is going to
terminate.

thrown, the situation is likely beyond repair.

Then why api has provided mechanism to handle this exception ?
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By OutofMemoryException, do you mean OutOfMemoryError?

You have the facility to catch it the same way you have door handles inside a car which is travelling at 90mph. The door handles don't disappear when the car is moving, so you can still open the door and step out . . . but you don't
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good one .We may die if we take jump at that time
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you go back about 3 years on the Ranch (and search), there was somebody who had several lakh of objects in a List and was suffering OutOfMemoryErrors. He put code inside his catch(OutOfMemoryError) block to set most of the objects in that List to null, and they were deleted by the garbage collector, and his application continued to run.

But why didn't he set unneeded objects to null during the normal execution? That would be much better design.
 
reply
    Bookmark Topic Watch Topic
  • New Topic