zno2

StackOverflowError 和 OutOfMemoryError

 

package cn.zno.outofmomery;

import java.util.ArrayList;
import java.util.List;

public class Test {

    void s() {
        s();
    }

    void h() {
        List<byte[]> list = new ArrayList<byte[]>();
        while (true) {
            list.add(new byte[1024 * 1024]);
        }
    }

    public static void main(String[] args) {
     // new Test().s(); // StackOverflowError
        new Test().h(); // OutOfMemoryError
    }
}

 

posted on 2016-08-05 18:33  zno2  阅读(172)  评论(0编辑  收藏  举报

导航