I have an OOM error(Perm Gen is full), problem is when I am logging the error message into the log file, error occurs while the classloader is loading the exception handling class.
Asked
Active
Viewed 320 times
2 Answers
0
You shouldn't handle errors as your application is in abnormal state:
https://docs.oracle.com/javase/7/docs/api/java/lang/Error.html
This answer explains scenario where you might want to do it though:
-
I've never had any problem recovering from an `OutOfMemoryError` in particular. Some allocation failed, the try block got disrupted and the program happily continues on. ... The program *would* be in an inconsistent state if the body of the try block is designed badly, that is, if some user-imposed invariants are corrupted if interrupted half-way. – Mark Jeronimus Jan 31 '18 at 09:39
0
You can either throw this error to handle where you're using it or you can put a try catch block around your logic(code) and you can log the error inside the catch or finally block.

Rahul
- 863
- 6
- 23
-
I think you need to read the Java Doc, OutOfMemoryError is not an exception!!! https://docs.oracle.com/javase/7/docs/api/java/lang/OutOfMemoryError.html – Rahul Jan 31 '18 at 08:52