Documentation for java.lang.Error
says:
An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch
But as 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:
java.lang.OutOfMemoryError
might be a good idea?java.lang.OutOfMemoryError
, how can we make sure the catch handler doesn't allocate any memory by itself (any tools or best practices)?