JVM参数:
-server -Xmx2g -Xms2g -Xmn256m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -XX:+PrintGCDetails -Xloggc:logs/gc.log -XX:+PrintGCTimeStamps
Java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
GC日志:
4728.367: [GC (Allocation Failure) 4728.367: [ParNew: 210107K->314K(235968K), 0.0041113 secs] 650117K->440325K(2070976K), 0.0042571 secs] [Times: user=0.03 sys=0.00, real=0.01 secs]
4729.843: [GC (Allocation Failure) 4729.843: [ParNew: 210106K->4023K(235968K), 0.0061596 secs] 650117K->444034K(2070976K), 0.0063117 secs] [Times: user=0.04 sys=0.00, real=0.00 secs]
4730.447: [GC (Allocation Failure) 4730.447: [ParNew: 212630K->2166K(235968K), 0.0202457 secs] 652642K->442177K(2070976K), 0.0203974 secs] [Times: user=0.22 sys=0.01, real=0.02 secs]
4731.010: [GC (Allocation Failure) 4731.010: [ParNew: 211598K->1463K(235968K), 0.0256586 secs] 651610K->441475K(2070976K), 0.0258524 secs] [Times: user=0.04 sys=0.01, real=0.02 secs]
4731.583: [GC (Allocation Failure) 4731.583: [ParNew: 211255K->528K(235968K), 0.0200805 secs] 651267K->440572K(2070976K), 0.0202633 secs] [Times: user=0.10 sys=0.00, real=0.02 secs]
4732.153: [GC (Allocation Failure) 4732.153: [ParNew: 210320K->3971K(235968K), 0.0032271 secs] 650364K->444130K(2070976K), 0.0033627 secs] [Times: user=0.04 sys=0.00, real=0.00 secs]
我使用GCViewer!分析GC日志。
部分结果如下:
Total heap(usage / alloc.max) 625.9M(30.9%)/2,022.4M
Tenured heap(usage / alloc.max) 415M(23.2%)/1,792M
Young heap(usage / alloc.max) 212.5(92.2%)/230.4M
内存泄漏吗?或如何优化JVM参数?
答案 0 :(得分:0)
很难甚至无法判断此日志是否存在内存泄漏。
[GC (Allocation Failure)
表示无法在年轻代块中分配内存,此分配失败会触发垃圾收集器(GC)。
可以看出,为年轻一代分配的堆空间用完了92%,该程序需要更多的 new 内存,但是没有足够的新内存,因此GC具有进行清理以释放一些内存。
由于其他堆区域中仍有大量可用空间,因此我宁愿调查是什么导致程序如此快速地创建新对象,而不是调整JVM参数。