Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Link to my answer. <a href="https://stackoverflow.com/questions/16053559/simplest-ways-to-cause-stack-overflow-in-c-c-and-java/16053616#16053616">Simplest ways to cause stack overflow in C#, C++ and Java</a></p> <p><strong>This Explaination is the basic reason behind StackOverflowException for languages java, C, C++.</strong></p> <p>Stackoverflow exception is caused genrally in any language due to recursive method calls.</p> <p>Suppose you have an method which is calling itself or any other method for an infinite recursive loop then it will cause a Stacoverflowexception. The reason behind this is the method call stack gets filed and it wont be able to accommodate ant other method call.</p> <p><strong>Method call stack looks like this picture.</strong></p> <p><img src="https://i.stack.imgur.com/4Z6xK.png" alt="enter image description here"></p> <p><strong>Explanation</strong> -- Suppose Main method has five statements And third method has an call to methodA, then the execution of main method gets paused at statement3 and MethosA will be loaded into call stack. Then method A has a call to methodB. So methodB also gets loaded into the stack. </p> <p>So in this way infinite recursive calls makes call stack getting filled. So it cant afford any more methods. So it throws StackOverflowException.</p> <p><strong>And how to encounter it See this link</strong></p> <p><a href="https://stackoverflow.com/questions/16055441/computing-method-call-stack-size">Computing method call stack size for checking StackOverflowException</a></p> <p>I am also looking for solution of my this query.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload