标签:导出 xms ima and mic java se read mamicode bytes
测试堆内存溢出代码:
1 public class Demo { 2 3 }
1 import java.util.ArrayList; 2 import java.util.List; 3 4 public class Test { 5 public static void main(String[] args) { 6 List<Demo> demoList = new ArrayList(); 7 while(true) { 8 demoList.add(new Demo()); 9 } 10 } 11 }
错误:
1 Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
2 at java.util.Arrays.copyOf(Arrays.java:3210)
3 at java.util.Arrays.copyOf(Arrays.java:3181)
4 at java.util.ArrayList.grow(ArrayList.java:261)
5 at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:235)
6 at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:227)
7 at java.util.ArrayList.add(ArrayList.java:458)
8 at jvm.Test.main(Test.java:10)
给jvm传入参数 -XX:+HeapDumpOnOutOfMemoryError -Xms20m -Xmx20m 导出堆快照信息
错误:
java.lang.OutOfMemoryError: Java heap space Dumping heap to java_pid19356.hprof ... Heap dump file created [27964857 bytes in 0.107 secs] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:3210) at java.util.Arrays.copyOf(Arrays.java:3181) at java.util.ArrayList.grow(ArrayList.java:261) at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:235) at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:227) at java.util.ArrayList.add(ArrayList.java:458) at jvm.Test.main(Test.java:10)
使用MemoryAnalyzer 工具分析堆内存情况
标签:导出 xms ima and mic java se read mamicode bytes
原文地址:https://www.cnblogs.com/haoyujun135/p/12082797.html