title: Stanford-NLP : GC overhead limit excedded when using parser on Tomcat
body: <p>We are working on integrating Stanford NLP on our system and it is working fine, just that it causes <code>gc overhead limit exceeded</code>. WE have the memory dump and will analyze it, but if ányone has some idea about this issue, please let us know. The server is quite powerful, SSD, 32gb RAM, Xeon E5 series. </p>
  
  <p>Code we have:</p>
  
  <pre><code> String text = Jsoup.parse(groupNotes.getMnotetext()).text();
                  String lang;
                  try {
                      DetectorFactory.clear();
                      DetectorFactory.loadProfile("/home/deploy/profiles/");
                      Detector detector = DetectorFactory.create();
                      detector.append(text);
                       lang = detector.detect();
                  }catch (Exception ignored){
                      lang = "de";
                  }
  
                  LexicalizedParser lp;
                  if (lang.toLowerCase().equals("de")) {
                      lp = LexicalizedParser.loadModel(GERMAN_PCG_MODEL);
                  } else {
                      lp = LexicalizedParser.loadModel(ENGLISH_PCG_MODEL);
                  }
                  Tree parse;
                  parse = lp.parse(text);
                  List&lt;String&gt; stringList = new ArrayList&lt;&gt;();
                  List taggedWords = parse.taggedYield();
                 // System.out.println(taggedWords);
                  for (Object str : taggedWords) {
                      if (str.toString().contains("NN")) {
                          stringList.add(str.toString().replace("/NN", ""));
                      }
                      if (str.toString().contains("NNS")) {
                          stringList.add(str.toString().replace("/NNS", ""));
                      }
                      if (str.toString().contains("NNP")) {
                          stringList.add(str.toString().replace("/NNP", ""));
                      }
                      if (str.toString().contains("NNPS")) {
                          stringList.add(str.toString().replace("/NNPS", ""));
                      }
                      if (str.toString().contains("VB")) {
                          stringList.add(str.toString().replace("/VB", ""));
                      }
                      if (str.toString().contains("VBD")) {
                          stringList.add(str.toString().replace("/VBD", ""));
                      }
                      if (str.toString().contains("VBG")) {
                          stringList.add(str.toString().replace("/VBG", ""));
                      }
                      if (str.toString().contains("VBN")) {
                          stringList.add(str.toString().replace("/VBN", ""));
                      }
                      if (str.toString().contains("VBZ")) {
                          stringList.add(str.toString().replace("/VBZ", ""));
                      }
                      if (str.toString().contains("VBP")) {
                          stringList.add(str.toString().replace("/VBP", ""));
                      }
                      if (str.toString().contains("JJ")) {
                          stringList.add(str.toString().replace("/JJ", ""));
                      }
                      if (str.toString().contains("JJR")) {
                          stringList.add(str.toString().replace("/JJR", ""));
                      }
                      if (str.toString().contains("JJS")) {
                          stringList.add(str.toString().replace("/JJS", ""));
                      }
                      if (str.toString().contains("FW")) {
                          stringList.add(str.toString().replace("/FW", ""));
                      }
                  }
  </code></pre>
  
  <p>JVM options for Apache tomcat :</p>
  
  <pre><code>CATALINA_OPTS="$CATALINA_OPTS -server -Xms2048M -Xmx3048M -XX:OnOutOfMemoryError="/home/deploy/scripts/tomcatrestart.sh" -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemory -XX:HeapDumpPath=/path/to/date.hprof -XX:-UseGCOverheadLimit -Dspring.security.strategy=MODE_INHERITABLETHREADLOCAL"
  </code></pre>
  
  <p>Any ideas? </p>
  
  <p>POM.xml :</p>
  
  <pre><code>  &lt;dependency&gt;
              &lt;groupId&gt;edu.stanford.nlp&lt;/groupId&gt;
              &lt;artifactId&gt;stanford-corenlp&lt;/artifactId&gt;
              &lt;version&gt;3.7.0&lt;/version&gt;
              &lt;classifier&gt;models&lt;/classifier&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;edu.stanford.nlp&lt;/groupId&gt;
              &lt;artifactId&gt;stanford-corenlp&lt;/artifactId&gt;
              &lt;version&gt;3.7.0&lt;/version&gt;
              &lt;classifier&gt;models-german&lt;/classifier&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
   &lt;dependency&gt;
              &lt;groupId&gt;edu.stanford.nlp&lt;/groupId&gt;
              &lt;artifactId&gt;stanford-parser&lt;/artifactId&gt;
              &lt;version&gt;3.7.0&lt;/version&gt;
           &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
  
       &lt;dependency&gt;
              &lt;groupId&gt;edu.stanford.nlp&lt;/groupId&gt;
              &lt;artifactId&gt;stanford-corenlp&lt;/artifactId&gt;
              &lt;version&gt;3.7.0&lt;/version&gt;
           &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  </code></pre>