JVM虚拟机栈和本地方法栈溢出测试

时间:2022-12-27 21:46:06

弄JAVA,那JVM,JAVA语法,JDK库,JAVAEE,流行框架是一个都不能少,才可以有全局感的。

JVM高级特性这书,看得差不多了。慢慢实践。

/**
 * 
 * 
 *VM Args: -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError
 *@author hengheng
 */
public class HeapOOM {
    private int stackLength = 1;
    public void stackLeak() {
        stackLength++;
        stackLeak();
        }
        
    public static void main(String[] args) throws Throwable {
        HeapOOM oom = new HeapOOM();
        try {
                oom.stackLeak();
        } catch (Throwable e) {
                System.out.println("stack length:" + oom.stackLength);
                throw e;
                }

    }

}

JVM虚拟机栈和本地方法栈溢出测试