java.lang.StackOverflowError: stack size 8MB Problem

How Can i Solve this Problem.

java.lang.StackOverflowError: stack size 8MB

2019-08-24%20at%2013-29-02

Did you search the forum? Then you would have found this. Is this related to your problem?

You created a infinity loop. :no_mouth:

Give now Tony Stark the infinity stones back!

6 Likes

#This Blocks are Can Not Working…

2019-08-24%20at%2013-44-19

How Can i Finish the Loop.

I have done a snap now. :ok_hand:
After you change the blocks the universum would forgot this bug.


Change If then If then to…
If then, else if

8 Likes

Presenting… Mikanos. :joy:

2 Likes

I have the same error but i am not using view pager , and how can i solve this problem

it means you don’t have enough memory to load some assets from the app… try checking your assets size or review your blocks

You have an endless loop in your code

/Boban

Can you show a demo how a endless loop occurs

Button 1 onClick -> perform Button 2 Click
Button 2 onClick -> perform Button 1 Click

Now you have a endless loop…

2 Likes

If i set like this ,
If its behave like a loop or not ?

Why you are using 3 clocks instead of a counter variable?

5 Likes

Can you so me a example how to use it

In my project i have found the loop ,
the loop is in the below blockes , where every time the ad is unable to load and recall the ad to load again. Now its again and again failed and a loop was created.
:grin::grin::grin::grin:

2 Likes

A StackOverflowError is simply signals that there is no more memory available. It is to the stack what an OutOfMemoryError is to the heap: it simply signals that there is no more memory available. JVM has a given memory allocated for each stack of each thread, and if an attempt to call a method happens to fill this memory, JVM throws an error. Just like it would do if you were trying to write at index N of an array of length N. No memory corruption can happen. The stack can not write into the heap.

The common cause for a stackoverflow is a bad recursive call. Typically, this is caused when your recursive functions doesn’t have the correct termination condition, so it ends up calling itself forever. Or when the termination condition is fine, it can be caused by requiring too many recursive calls before fulfilling it.

Here’s an example:

public class Overflow {
    public static final void main(String[] args) {
        main(args);
    }
}

That function calls itself repeatedly with no termination condition. Consequently, the stack fills up because each call has to push a return address on the stack, but the return addresses are never popped off the stack because the function never returns, it just keeps calling itself.

2 Likes

ViewPager position start from 0. But i am started from 1 so this problem was shown. Now this problem is solved.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.