【问题标题】:Exceptions that may not be logged due to lack of resources由于资源不足而可能无法记录的异常
【发布时间】:2016-07-15 23:24:22
【问题描述】:

我在使用 finally 块记录 OutOfMemoryError 时遇到问题,因为在写入日志之前引发了新的 OutOfMemoryError。

这很奇怪,因为只看日志似乎工作突然在过程中间完成而没有错误。

还有其他常见的情况会发生这种情况吗?考虑到我的 finally 块只是将日志写入文件。

【问题讨论】:

    标签: java logging exception-handling out-of-memory try-catch


    【解决方案1】:

    这些类型的错误和异常称为Asynchronous Exceptions。最好的做法是尝试调整您的 JVM 或您的代码,以便首先发生这种情况。

    您可能还想查看-XX:OnOutOfMemoryError-XX:+HeapDumpOnOutOfMemory 命令行选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-04
      • 2020-03-20
      • 1970-01-01
      • 2018-03-22
      • 2018-03-03
      • 2014-07-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多