What is a StackOverflow Error

0 votes
What is a StackOverflow Error? How does it occur? How should I work-out with it?
May 22, 2018 in Java by sharth
• 3,370 points
2,136 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 22, 2018 by Parth
• 4,640 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 29, 2020 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
• 59,230 points
1,298 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,220 points
5,178 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,190 points
958 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
• 59,230 points
1,844 views
+1 vote
2 answers
+9 votes
16 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,620 points
463,850 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,920 points
5,881 views
0 votes
4 answers

“Cannot find symbol” compilation error

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

answered Dec 16, 2020 in Java by Gitika
• 65,770 points
42,404 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,140 points
1,398 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,920 points
933 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP