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,350 points
105 views

1 answer 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 parth295
• 4,640 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 in Java by Sirajul
• 37,480 points
76 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,190 points
387 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,150 points
97 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 in Java by Sirajul
• 37,480 points
91 views
+1 vote
2 answers
+9 votes
11 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,540 points
43,733 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,880 points
1,345 views
0 votes
2 answers

“Cannot find symbol” compilation error

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

answered Apr 3 in Java by patricblues
• 140 points
8,971 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,050 points
66 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,880 points
246 views