当堆看起来仍然有很大的空间时,我得到了OutOfMemoryException。
我自己的日志报告-虚拟机内存使用了22.28G / 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特有的。在Java8上使用默认gc算法时,内存利用率在抛出OutOfMemoryException之前更接近-mx48G阈值。
我使用了以下参数-XX:+UseG1GC -mx48G
发布于 2019-10-03 05:05:11
在Java 11中尝试了相同的用例。它几乎在同一时间耗尽了内存,但报告的内存利用率为98%。这事儿可以理解。
Java 8似乎错误地报告了内存使用情况。
https://stackoverflow.com/questions/58173068
复制相似问题