Results 1 to 5 of 5
Like Tree2Likes
  • 1 Post By JosAH
  • 1 Post By JosAH

Thread: How many times can a method call itself until it gets stack overflow?

  1. #1
    EscSequenceAlpha is offline Senior Member
    Join Date
    Apr 2012
    Posts
    115
    Rep Power
    0

    Default How many times can a method call itself until it gets stack overflow?

    I'm curious about the limitations of recursion
    Legend has it the moderators and senior members of java-forums.org were able to code skyrim using only 701 lines of java... or so the legend goes.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,365
    Blog Entries
    7
    Rep Power
    20

    Default Re: How many times can a method call itself until it gets stack overflow?

    That depends on two things: the number of parameters and local variables of the method and the maximum stack size allowed for a thread. See the -xms flag for the maximum stack size. The stack can usually grow up to 128MB or so.

    kind regards,

    Jos
    EscSequenceAlpha likes this.
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    EscSequenceAlpha is offline Senior Member
    Join Date
    Apr 2012
    Posts
    115
    Rep Power
    0

    Default Re: How many times can a method call itself until it gets stack overflow?

    I see so each thread has its own stack.

    so with one parameter and one variable of int that would 64 bits per call, but then theres probably some overhead like pointers and such... I dont really know how this works can you add more detail?
    Legend has it the moderators and senior members of java-forums.org were able to code skyrim using only 701 lines of java... or so the legend goes.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,365
    Blog Entries
    7
    Rep Power
    20

    Default Re: How many times can a method call itself until it gets stack overflow?

    Quote Originally Posted by EscSequenceAlpha View Post
    I see so each thread has its own stack.

    so with one parameter and one variable of int that would 64 bits per call, but then theres probably some overhead like pointers and such... I dont really know how this works can you add more detail?
    If you want all the details, read the VM Specification.

    kind regards,

    Jos
    DarrylBurke likes this.
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: How many times can a method call itself until it gets stack overflow?

    i'm curious about the limitations of recursion
    ram?

Similar Threads

  1. Stack Overflow?
    By kyle_maddisson in forum New To Java
    Replies: 5
    Last Post: 11-17-2011, 11:49 AM
  2. Preventing stack overflow?
    By bobocheez in forum New To Java
    Replies: 11
    Last Post: 01-05-2011, 05:50 PM
  3. Replies: 1
    Last Post: 03-17-2010, 05:25 AM
  4. Stack Overflow work around?
    By Coukapecker in forum New To Java
    Replies: 2
    Last Post: 03-14-2010, 08:49 PM
  5. Java Stack Overflow?
    By fullmetaljacket in forum New To Java
    Replies: 0
    Last Post: 05-19-2009, 07:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •