title: JAVA processing file with java.lang.OutOfMemoryError: GC overhead limit exceeded error
body: <p>I have the following JAVA class to read from a file containing many lines of tab delimited strings. An example line is like the following: </p>
  
  <pre><code>GO:0085044      GO:0085044      GO:0085044
  </code></pre>
  
  <p>The code read each line and use split function to put three sub strings into an array, then it put them into a two level hash.</p>
  
  <pre><code>public class LCAReader {
      public static void main(String[] args) {
          Map&lt;String, Map&lt;String, String&gt;&gt; termPairLCA = new HashMap&lt;String, Map&lt;String, String&gt;&gt;();
          File ifile = new File("LCA1.txt");
          try {
              BufferedReader reader = new BufferedReader(new FileReader(ifile));
              String line = null;
              while( (line=reader.readLine()) != null ) {
                  String[] arr = line.split("\t");
                  if( termPairLCA.containsKey(arr[0]) ) {
                      if( termPairLCA.get(arr[0]).containsKey(arr[1]) ) {
                          System.out.println("Error: Duplicate term in LCACache");
                      } else {
                          termPairLCA.get(arr[0]).put(new String(arr[1]), new String(arr[2]));
                      }
                  } else {
                      Map&lt;String, String&gt; tempMap = new HashMap&lt;String, String&gt;();
                      tempMap.put( new String(arr[1]), new String(arr[2]) );
                      termPairLCA.put( new String(arr[0]), tempMap );
                  }
              }
              reader.close();
          } catch (IOException e) {
              System.out.println(e.getMessage());
          }
      }
  }
  </code></pre>
  
  <p>When I ran the program, I got the following run time error after some time of running. I noticed the memory usage kept increasing. </p>
  
  <p>Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
          at java.util.regex.Pattern.compile(Pattern.java:1469)
          at java.util.regex.Pattern.(Pattern.java:1150)
          at java.util.regex.Pattern.compile(Pattern.java:840)
          at java.lang.String.split(String.java:2304)
          at java.lang.String.split(String.java:2346)
          at LCAReader.main(LCAReader.java:17)</p>
  
  <p>The input file is almost 2G and the machine I ran the program has 8G memory. I also tried -Xmx4096m parameter to run the program but that did not help. So I guess there is some memory leak in my code, but I cannot find them.</p>
  
  <p>Can anyone help me on this? Thanks in advance!</p>