jdk JAVA Development Kit java开发工具集
JRE Java Runtime Environment Java运行环境
Jvm Java Virtual Machine Java虚拟机
jdk = java语言+Tools +Tool APIs
Jre = Jvm + Java SE API + Deployment (Java7版本Jvm在java se Api中)
Java SE API = Compact Profiles + User Interface Toolkits
User Interface Toolkits = lang and util Base Libraries + Other Base Libraries + Integration Libraries
Java API java类库
测试堆内存溢出代码:
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 工具分析堆内存情况
原文地址:https://www.cnblogs.com/haoyujun135/p/12082797.html
时间: 2024-10-29 21:34:00