How do I make the JVM exit on ANY OutOfMemoryException even when bad people try to catch it

后端 未结 10 524
醉梦人生
醉梦人生 2020-12-09 16:32

An OOME is of the class of errors which generally you shouldn\'t recover from. But if it is buried in a thread, or someone catches it, it is possible for an application to g

10条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-09 16:50

    Only thing I can think of is using AOP to wrap every single method (beware to rule out java.*) with a try-catch for OOME and if so, log something and call System.exit() in the catch block.

    Not a solution I'd call elegant, though...

提交回复
热议问题