1

I have written the code to get the size of the stack of my computer.

public class TestStack {

  private static int c;

  public static void main(String... args){
    try{
      f();
    } catch (StackOverflowError e){
      System.out.println(c);
    }
  }

  private static void f(){
    c ++;
    f();
  }
}

The result of its work is: 11908

What sets the size of the stack (JVM, OS or something else)? Is it possible to change the stack size?

Mikhail
  • 53
  • 1
  • 8

1 Answers1

1

the JVM and yes you can pass parms to change the stack size. This question/answer is somewhat close to your question. How to increase the Java stack size?

Community
  • 1
  • 1