• 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

Error --OutOfMemoryError

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can we catch an Error, ex. OutOfMemoryError.
What actually happens in that case.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shivaprakash Shettihalli,
Please take the time to choose the correct forum for your question.
Moving Java in General Intemediate.
 
Sheriff
Posts: 22785
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can catch any Throwable, so that includes Exceptions, RuntimeExceptions and Errors.

You catch an OutOfMemoryException (OOME), but the exception handler will most likely throw another OOME.

The OOME is only thrown when the JVM really runs out of memory. If the JVM needs more memory, it will always first run the Garbage Collector to see if it can free up some more memory. Only if afterwards there still isn't enough free memory the OOME will be thrown.
 
reply
    Bookmark Topic Watch Topic
  • New Topic