title: Resolve java.lang.StackOverflowError memory problem
body: <p>I'm using a recursive function, and I'm getting this error when I execute :</p>
  
  <pre><code>Exception in thread "main" java.lang.StackOverflowError
      at java.util.HashMap$Entry.&lt;init&gt;(Unknown Source)
      at java.util.HashMap.addEntry(Unknown Source)
      at java.util.HashMap.put(Unknown Source)
  </code></pre>
  
  <p>I debeugged the method and 100% sure it ends at some point.</p>
  
  <p>So I think its related to a memory problem.</p>
  
  <p>Is there any solution ?</p>
  
  <blockquote>
    <p>EDIT:</p>
  </blockquote>
  
  <pre><code>public static Vector&lt;String&gt; _toOpen;
  
  public static void openFiles(Vector&lt;String&gt; files)
  {       
     ...
  
      while(actualFile.hasNext)
      {
          if(!_toOpen.contains(word))
          {
             _toOpen.add(word);
              System.out.println("word");
          }
      }
  
     ...
  
     if(_toOpen.size() &gt; 0)
     {
         openFiles(_toOpen);
     }
  }
  </code></pre>
  
  <p>At the first call I pass to OpenFiles a Vector wich contains a list of files to open, each file has a list of files to open again and so on ...</p>
  
  <p>What I'm doing is preventing a file to be opened if it was dopne before.</p>