jvm——虚拟机栈内存溢出
程序员文章站
2022-06-07 08:48:07
...
1、示例代码
package com.memory;
/**
* @author dc
* @date 2020/6/28 - 9:58
*/
/**
* 虚拟机栈溢出
*/
public class MyTest2 {
private int length;
public int getLength() {
return length;
}
public void test() {
this.length ++;
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
test();
}
public static void main(String[] args) {
MyTest2 mytest2 = new MyTest2();
try {
mytest2.test();
} catch (Throwable ex) {
System.out.println(mytest2.getLength());
ex.printStackTrace();
}
}
}
2、运行结果
下一篇: Docker基础概念介绍及安装