stack=java.lang.StackOverflowError: stack size 8MB
<p>I'm getting this StackOverFlow error, i understand it fully, but the issue is im not dealing with big data, So how can this error be produced ? </p>

<p>I have an activity, Framelayout, a fragment, 3 options.</p>

<p>In the fragment, when you click on one of those options, it re-create the fragment and put random numbers, the MAX is <code>15</code>, So its not that big, this error happens when the user click so fast on the options which cause this overflow.</p>

<p>This is the code for generating, any ideas about "enhancing" it ? i don't know if this code is a bad practice for momery using.</p>

<pre><code>private static List&lt;Integer&gt; SavedNumbers;

public static void SetupSavedNumbersLIst(){
    SavedNumbers = new ArrayList&lt;&gt;();
}


static List&lt;Integer&gt; range;
private static void AddDiff(int mMAX){
    range = new ArrayList&lt;&gt;();
    for(int i = 0 ; i &lt; mMAX ; i++){
        range.add(i);
    }

    range.removeAll(SavedNumbers);
}

private static int ReturnIfDuplic(int mMAX){
    AddDiff(mMAX);
    return new Random().nextInt(range.size());
}


public static int ReturnUniqueSavedNumber(int mMAX){
    int Random = ReturnRandom(mMAX);
    if(SavedNumbers != null &amp;&amp; SavedNumbers.size() &gt; 0) {
        if(DoesSavedNumberExist(Random)){
            return ReturnIfDuplic(mMAX);
        } else {
            SavedNumbers.add(Random);
            return Random;
        }
    } else if (SavedNumbers != null &amp;&amp; SavedNumbers.size() == 0){
        SavedNumbers.add(Random);
        return Random;
    } else if( SavedNumbers == null){
        SetupSavedNumbersLIst();
        return ReturnUniqueSavedNumber(mMAX);
    } else {
        return 1;
    }
}

private static boolean DoesSavedNumberExist(int Number){
    for(int s: SavedNumbers){
        if(Number == s)
            return true;
    }
    return false;
}

private static int ReturnRandom(int mMAX){
    return new Random().nextInt(mMAX);
}
</code></pre>