title: How to increase Java heap space for a tomcat app
body: <p>There are lots of questions that ask this or a similar question.</p>
  
  <p>They all give the command that has to be executed, what I don't understand is where do I write this command. I want to permanently increase the heap space for my tomcat apps.</p>
  
  <p>I read this page <a href="http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html" rel="noreferrer"><a href="http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html" rel="noreferrer">http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html</a></a> and it says under the Tomcat section </p>
  
  <blockquote>
    <p>Stop Tomcat server, set environment variable CATALINA_OPTS, and then restart Tomcat. Look at the file tomcat-install/bin/catalina.sh or catalina.bat for how this variable is used. For example,</p>
    
    <p>set CATALINA_OPTS=-Xms512m -Xmx512m  (Windows, no "" around the value)<br>
    export CATALINA_OPTS="-Xms512m -Xmx512m"  (ksh/bash, "" around the value)<br>
    setenv CATALINA_OPTS "-Xms512m -Xmx512m"  (tcsh/csh, "" around the value)</p>
  </blockquote>
  
  <p>So I replaced the line </p>
  
  <blockquote>
    <p>set CATALINA_OPTS= </p>
  </blockquote>
  
  <p>with </p>
  
  <blockquote>
    <p>set CATALINA_OPTS=-Xms512m -Xmx512m  </p>
  </blockquote>
  
  <p>But I still get the error.</p>
  
  <blockquote>
    <p>javax.servlet.ServletException: Servlet execution threw an exception</p>
    
    <p>root cause</p>
    
    <p>java.lang.OutOfMemoryError: Java heap space
        java.lang.reflect.Array.multiNewArray(Native Method)
        java.lang.reflect.Array.newInstance(Array.java:90)
        nom.tam.util.ArrayFuncs.newInstance(ArrayFuncs.java:1028)
        nom.tam.fits.ImageData.read(ImageData.java:259)
        nom.tam.fits.Fits.readHDU(Fits.java:573)
        controller.UploadServlet.retreiveFITSFileFields(UploadServlet.java:206)
        controller.ScanServerFiles.doPost(ScanServerFiles.java:39)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)</p>
  </blockquote>