title: java.lang.OutOfMemoryError: Java heap space on using ArrayLists
body: <pre><code>Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
      at java.util.Arrays.copyOf(Unknown Source)
      at java.util.Arrays.copyOf(Unknown Source)
      at java.util.ArrayList.grow(Unknown Source)
      at java.util.ArrayList.ensureExplicitCapacity(Unknown Source)
      at java.util.ArrayList.ensureCapacityInternal(Unknown Source)
      at java.util.ArrayList.add(Unknown Source)
      at FibonacciHeap.removemax(FibonacciHeap.java:148)
      at UseFibonacciHeap.main(UseFibonacciHeap.java:61)
  </code></pre>
  
  <p>My java program on Eclipse is reading strings from a file and inserting them to an array list and doing a lot of computations ahead.It throws the above exceptions on encountering 150+ strings.I tried increasing the VM space,using sleep but Nothing works ! 
  The eventual goal is to operate on 1 million strings(not all unique). </p>
  
  <p>Edits:</p>
  
  <p>Usage of the ArrayList toVisit:</p>
  
  <pre><code>for (FibonacciNode curr = max_ptr; toVisit.isEmpty() || toVisit.get(0) != curr; curr = curr.right_sibling)
  {
       toVisit.add(curr);
       ...
  }
  </code></pre>
  
  <p>VM Arguments for the class:
  -Xms1024M -Xmx1524M</p>
  
  <p>Can someone guide me to an optimal way of doing this.Is there a different data structure that I can use? Thanks !! </p>