Behavior of a Java process in case of OutOfMemoryError

后端 未结 3 1179
暗喜
暗喜 2020-12-19 05:16

What would be the behavior of a Java program on getting OutOfMemoryError. Is there any defined behavior? Will the process crash or would it go into wait/sleep state?

3条回答
  •  孤城傲影
    2020-12-19 05:55

    OutOfMemoryError should be considered unrecoverable and the behavior of the JVM after such an error has been raised is undefined, so there is no point in expending effort to handle it. Any operations done after this exception is thrown by the JVM will have undefined behavior. They may execute, but more likely they will just cause another error to be thrown.

提交回复
热议问题