竹笋

首页 » 问答 » 常识 » JVM结合MAT工具来分析OOM问题
TUhjnbcbe - 2023/10/7 16:59:00
北京一次治疗白癜风花多少钱 http://m.39.net/news/a_5188236.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问题