【问题标题】:OutOfMemoryException while heap is half full堆半满时出现 OutOfMemoryException
【发布时间】:2019-09-30 18:06:46
【问题描述】:

我得到了OutOfMemoryException,而堆似乎还有足够的空间。

我自己的日志报告 - VM Memory used 22.28G out of 48G

来自-XX:+PrintGCDetails -XX:+PrintAdaptiveSizePolicy -XX:+UnlockDiagnosticVMOptions -XX:+G1PrintHeapRegions 的日志似乎同意只使用 25G 出 48G

[Eden: 0.0B(2448.0M)->0.0B(2448.0M) Survivors: 0.0B->0.0B Heap: 24.9G(48.0G)->24.9G(48.0G)]

 159.360: [G1Ergonomics (Heap Sizing) attempt heap expansion, reason: allocation request failed, allocation request: 48 bytes]
 159.360: [G1Ergonomics (Heap Sizing) expand the heap, requested expansion amount: 16777216 bytes, attempted expansion amount: 16777216 bytes]
 159.360: [G1Ergonomics (Heap Sizing) did not expand the heap, reason: heap already fully expanded]

这个问题似乎是 G1 特有的。在 Java 8 上使用默认的 gc 算法时,内存利用率在抛出OutOfMemoryException 之前会更接近-mx48G 阈值。

我正在使用以下参数 -XX:+UseG1GC -mx48G

【问题讨论】:

    标签: java memory garbage-collection


    【解决方案1】:

    在 Java 11 中尝试了相同的用例。它几乎在同一时间耗尽了内存,但报告的内存利用率为 98%。这是有道理的。

    似乎 Java 8 错误地报告了内存利用率。

    【讨论】:

      猜你喜欢
      • 2012-03-10
      • 2012-10-05
      • 2020-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-29
      • 2012-01-27
      • 2014-09-30
      相关资源
      最近更新 更多