Is there any point catching an out of memory error (java.lang.OutOfMemoryError) in Java?
Is there any point catching an out of memory error ( java.lang.OutOfMemoryError ) in
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. Here are a few examples where it could make sense:
However, note that normally (unless you’re at a spot where you’ll be allocating tons of memory at once), you probably wouldn’t specifically catch OutOfMemoryError for these cases, but rather do a
catch Throwableall the way at the top in your main entry point.