1.1.1 內存用完【堆內存】java
package com.cnblogs.mufasa; import org.junit.Test; import java.util.ArrayList; public class Model { @Test public void test(){ ArrayList<Integer> arr=new ArrayList<>(); while (true){ arr.add(1); } } } /* java.lang.OutOfMemoryError: Java heap space */
1.1.2 沒有退出的遞歸調用緩存
package com.cnblogs.mufasa.SOF; import org.junit.Test; public class SOF_validate1 { public void recursive(){ int cnt=0; StringBuilder sb=new StringBuilder(); while (cnt<1){ sb.append(new String(""+cnt)); cnt++; } recursive(); } @Test public void test(){ recursive();//沒有退出條件的遞歸 } } /* java.lang.StackOverflowError */
https://blog.csdn.net/qq_16973111/article/details/81258480app