title: Java Heap Space error on Stanford NER using Netbeans
body: <p>I am using Stanford NER to parse a sentence for getting following tags : tokenize,ssplit,pos,lemma,ner. I also increased memory in netbeans by Project->Properties->Run->VM Options to <code>-Xms1600M -Xmx1600M</code>. Still I am getting Java out of memory exception.
  I am running 32-bit java, on windows 7 JDK version 1.7.
  Here is my code </p>
  
  <pre><code>public ArrayList&lt;String&gt; NERTokensRet(String string) {
      ArrayList&lt;String&gt; myArr = new ArrayList&lt;String&gt;();
  
  
      props = new Properties();
      props.put("annotators", "tokenize,ssplit,pos,lemma,ner");
      pipeline = new StanfordCoreNLP(props);
  
  
      //     String resultString = string.replaceAll("[^\\p{L}\\p{N}]", " ");   
      Annotation annotation = new Annotation(string);
      pipeline.annotate(annotation);
      int j;
      for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
          List&lt;CoreLabel&gt; tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);
  
          for (j = 0; j &lt; tokens.size(); j++) {
              CoreLabel token = tokens.get(j);
              myArr.add("[" + token.originalText() + "," + token.tag() + "," + token.beginPosition() + "," + token.endPosition() + "]");
          }
          //System.out.println(myArr);
      }
  
      return myArr;
  }
  </code></pre>
  
  <p>StackTrace : </p>
  
  <pre><code>Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
  at java.lang.AbstractStringBuilder.&lt;init&gt;(AbstractStringBuilder.java:45)
  at java.lang.StringBuilder.&lt;init&gt;(StringBuilder.java:68)
  at java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(ObjectInputStream.java:2998)
  at java.io.ObjectInputStream$BlockDataInputStream.readUTF(ObjectInputStream.java:2819)
  at java.io.ObjectInputStream.readString(ObjectInputStream.java:1598)
  at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1319)
  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
  at java.util.HashMap.readObject(HashMap.java:1030)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
  at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848)
  at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
  at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
  at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
  at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
  at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
  at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
  at edu.stanford.nlp.ie.crf.CRFClassifier.loadClassifier(CRFClassifier.java:2255)
  at edu.stanford.nlp.ie.AbstractSequenceClassifier.loadClassifier(AbstractSequenceClassifier.java:1444)
  at edu.stanford.nlp.ie.AbstractSequenceClassifier.loadClassifier(AbstractSequenceClassifier.java:1421)
  at edu.stanford.nlp.ie.AbstractSequenceClassifier.loadClassifier(AbstractSequenceClassifier.java:1500)
  at edu.stanford.nlp.ie.AbstractSequenceClassifier.loadClassifier(AbstractSequenceClassifier.java:1487)
  at edu.stanford.nlp.ie.crf.CRFClassifier.getClassifier(CRFClassifier.java:2386)
  at edu.stanford.nlp.ie.ClassifierCombiner.loadClassifierFromPath(ClassifierCombiner.java:130)
  at edu.stanford.nlp.ie.ClassifierCombiner.loadClassifiers(ClassifierCombiner.java:116)
  at edu.stanford.nlp.ie.ClassifierCombiner.&lt;init&gt;(ClassifierCombiner.java:98)
  at edu.stanford.nlp.ie.NERClassifierCombiner.&lt;init&gt;(NERClassifierCombiner.java:64)
  at edu.stanford.nlp.pipeline.StanfordCoreNLP$6.create(StanfordCoreNLP.java:500)
  </code></pre>
  
  <p>Can some one please help as soon as possible?</p>