看一段 GC 日志:在 Full GC 結束後, 但是老年代占用空間還是接近或者等於老年代最大空間, 說明老年代空間確實分配不夠。 調大 -Xms、 -Xmx 並保持新生代大小不變,直到 GC 日志不出現關鍵字 Exception in thread “main” java.lang.OutOfMemoryError: Java heap space。
2016-01-19T14:18:19.883+0800: 179.163: [CMS-concurrent-reset-start] 2016-01-19T14:18:19.893+0800: 179.173: [CMS-concurrent-reset: 0.009/0.009 secs] [Times: user=0.02 sys=0.00, real=0.01 secs] {Heap before GC invocations=154 (full 1): par new generation total 943744K, used 850746K [0x0000000757000000, 0x0000000797000000, 0x0000000797000000) eden space 838912K, 100% used [0x0000000757000000, 0x000000078a340000, 0x000000078a340000) from space 104832K, 11% used [0x000000078a340000, 0x000000078aecea30, 0x00000007909a0000) to space 104832K, 0% used [0x00000007909a0000, 0x00000007909a0000, 0x0000000797000000) concurrent mark-sweep generation total 1560576K, used 1560576K [0x0000000797000000, 0x00000007f6400000, 0x00000007f6400000) concurrent-mark-sweep perm gen total 159744K, used 69030K [0x00000007f6400000, 0x0000000800000000, 0x0000000800000000)
(2) 永久代內存不足 看一段 GC 日志:在 Full GC 結束後, 但是永久代占用空間還是接近或者等於永久代最大空間, 說明永久代空間確實分配不夠。 調大 -XX:PermSize、 -XX:MaxPermSize,直到 GC 日志不出現關鍵字 Exception in thread “main” java.lang.OutOfMemoryError: PermGen space。
2016-01-19T14:18:19.883+0800: 179.163: [CMS-concurrent-reset-start] 2016-01-19T14:18:19.893+0800: 179.173: [CMS-concurrent-reset: 0.009/0.009 secs] [Times: user=0.02 sys=0.00, real=0.01 secs] {Heap before GC invocations=154 (full 1): par new generation total 943744K, used 850746K [0x0000000757000000, 0x0000000797000000, 0x0000000797000000) eden space 838912K, 100% used [0x0000000757000000, 0x000000078a340000, 0x000000078a340000) from space 104832K, 11% used [0x000000078a340000, 0x000000078aecea30, 0x00000007909a0000) to space 104832K, 0% used [0x00000007909a0000, 0x00000007909a0000, 0x0000000797000000) concurrent mark-sweep generation total 1560576K, used 345246K [0x0000000797000000, 0x00000007f6400000, 0x00000007f6400000) concurrent-mark-sweep perm gen total 159744K, used 159744K [0x00000007f6400000, 0x0000000800000000, 0x0000000800000000)