竹笋

首页 » 问答 » 问答 » JVM结合MAT工具来分析OOM问题
TUhjnbcbe - 2023/4/4 15:39:00

简单来演示一下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问题