竹笋

首页 » 问答 » 常识 » JVM结合MAT工具来分析OOM问题
TUhjnbcbe - 2024/10/19 20:48:00
中科治白癜风疗效更显著 http://www.gpitp.gd.cn/news/20180503/85432.html

简单来演示一下OOM的分析和实战。

直接上代码:

publicclassDemo4{publicstaticvoidmain(String[]args){ListDandanlist=newArrayList();while(true){list.add(newDandan());}}}classDandan{}

JVM参数:

-XX:+UseParNewGC-XX:+UseConcMarkSweepGC-Xms10m-Xmx10m-XX:+PrintGCDetails-Xloggc:gc_dandan.log-XX:+HeapDumpOnOutOfMemoryError-XX:HeapDumpPath=./

运行后的日志:

java.lang.OutOfMemoryError:JavaheapspaceDumpingheapto./java_pid.hprof...Heapdumpfilecreated[bytesin0.secs]Exceptioninthreadmainjava.lang.OutOfMemoryError:Javaheapspaceatjava.util.Arrays.copyOf(Arrays.java:)atjava.util.Arrays.copyOf(Arrays.java:)atjava.util.ArrayList.grow(ArrayList.java:)atjava.util.ArrayList.ensureExplicitCapacity(ArrayList.java:)atjava.util.ArrayList.ensureCapacityInternal(ArrayList.java:)atjava.util.ArrayList.add(ArrayList.java:)at

1
查看完整版本: JVM结合MAT工具来分析OOM问题