An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch
java.lang.Error is a subclass of
java.lang.Throwable, I can catch this type of Throwable.
I understand why it's not a good idea to catch this sort of exception. As far as I understand, if we decide to catch it, the catch handler should not allocate any memory by itself. Otherwise
OutOfMemoryError will be thrown again.
So, my question is:
- Are there any real world scenarios when catching
java.lang.OutOfMemoryErrormight be a good idea?
- If we decide to catch
java.lang.OutOfMemoryError, how can we make sure the catch handler doesn't allocate any memory by itself (any tools or best practices)?