What is a StackOverflow Error

0 votes
What is a StackOverflow Error? How does it occur? How should I work-out with it?
May 21, 2018 in Java by sharth
• 3,370 points
293 views

2 answers to this question.

0 votes
Parameters and local variables are allocated on the stack (with reference types the object lives on the heap and a variable references that is object)

The stack typically lives at the upper end of your address space and as it is used up it heads towards the bottom of the address space (i.e. towards zero)

Your process also has a heap. As you allocate memory, this heap can grow towards the upper end of your address space.              

The common cause for a stack overflow is a bad recursive call. Typically, this is caused when your recursive functions do not have the correct termination condition, so it ends up calling itself forever. However, with GUI programming, it is possible to generate indirect recursion. For example, your app may be handling paint messages, and, while processing them, it calls a function that causes the system to send another paint message. Here you have explicitly called yourself, but the OS has done it.

To deal with them you'll need to examine your code. If you have got functions that call themselves then check that you've got a terminating condition. If you have then check that after calling the function you have the modified arguments, otherwise there'll be no visible change for the recursively called function.
answered May 21, 2018 by Parth
• 4,630 points
0 votes

stackoverflow error – StackOverflow Error in Java. This error is thrown to indicate that the application's stack was exhausted, due to deep recursion. The StackOverflow Error extends the Virtual Machine Error class, which indicates that the JVM is broken, or it has run out of resources and cannot operate.

answered Aug 28 by Pistle
• 1,000 points

Related Questions In Java

0 votes
2 answers

what is the best way to convert an ArrayList to a String

You could probably use the Joiner class ...READ MORE

answered Aug 19, 2019 in Java by Sirajul
• 58,020 points
167 views
0 votes
1 answer

What is the simplest way to read JSON from a URL in java

Read json from url use url.openStream() and read contents ...READ MORE

answered Jun 13, 2018 in Java by samarth295
• 2,200 points
1,962 views
0 votes
1 answer

What is an efficient way to implement a singleton pattern in Java?

Use an enum: public enum Foo { ...READ MORE

answered Jul 6, 2018 in Java by Akrati
• 3,170 points
210 views
0 votes
2 answers

What is the easiest way to iterate through the characters of a string in Java?

There are two approaches to this: for(int i ...READ MORE

answered Aug 19, 2019 in Java by Sirajul
• 58,020 points
309 views
+1 vote
2 answers
+8 votes
14 answers

Unable to resolve this error: "javac is not recognized as an internal or external command"

Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1.7.0_02\bin and ...READ MORE

answered May 23, 2018 in Java by Rishabh
• 3,580 points
200,078 views
0 votes
2 answers

Connection reset : java.net.SocketException

You should check whether the client program is ...READ MORE

answered Sep 6, 2018 in Java by Sushmita
• 6,890 points
2,579 views
0 votes
2 answers

“Cannot find symbol” compilation error

The "Cannot find symbol" errors generally occur when you ...READ MORE

answered Apr 3, 2019 in Java by patricblues
• 140 points
25,852 views
0 votes
2 answers

What is the difference between = and equals()?

The equals() method compares the "value" inside String instances ...READ MORE

answered Aug 13, 2018 in Java by Daisy
• 8,110 points
214 views
0 votes
2 answers

Is there a destructor in Java?

try (BufferedReader br = new BufferedReader(new FileReader(path))) ...READ MORE

answered Sep 4, 2018 in Java by Sushmita
• 6,890 points
314 views