java.lang.OutOfMemoryError: GC o

2020-05-18  本文已影响0人  邵红晓

oracle官网的解释:
The concurrent collector will throw an OutOfMemoryError if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be thrown. This feature is designed to prevent applications from running for an extended period of time while making little or no progress because the heap is too small. If necessary, this feature can be disabled by adding the option-XX:-UseGCOverheadLimit to the command line.

 private static final int _1MB= 1024 * 1024;  //约1m
    public static void main(String[] args) {
        //总共约8m多,堆大小设置不超过8388608B即8.388608m就会内存溢出,但是需要整数,小于8M就会重现这个错误
        byte[] a1, a2, a3, a4;
        a1 = new byte[2 * _1MB];
        a2 = new byte[2 * _1MB];
        a3 = new byte[2 * _1MB];
        a4 = new byte[2 * _1MB];
    }
java.lang.OutOfMemoryError: Java heap space
Dumping heap to D:\gc.hprof ...
Heap dump file created [8401640 bytes in 0.017 secs]
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at shengsiyuan.jdk8.jvmCon.GcOverhead.main(GcOverhead.java:14)

Leak Suspects

image.png

问题解决

上一篇下一篇

猜你喜欢

热点阅读