Thanks!
I'm learning JVM, and test VM stack overflow, found a strange phenomenon. I call a method recursively in two ways, but I was confused with result.
VM Options: -Xss108k -Xms10m -Xmx10m
only a stack deep counter in method. screenshot 1
I defined array in method, stack go more deeper. screenshot 2
public class T2 {
private int stackLength = 1;
public void stackLeak(){
long[] a = new long[2000]; //define this array or not
stackLength++;
stackLeak();
}
public static void main(String[] args) {
T2 oom = new T2();
try{ //
oom.stackLeak();
} catch(Throwable e){
System.out.println("stack length: " + oom.stackLength);
e.printStackTrace();
} finally{
}
}
}
I have re-run many times, results almost the same. I thought, array saved in heap, it won't affect VM stack, but it did.