Search code examples
javatomcatheap-memorywarjruby

java.lang.OutOfMemoryError: Java heap space deploying .war on Tomcat 7


Getting below error when running the war file in tomcat7 (Ubuntu):

Exception in thread "http-bio-8080-AsyncTimeout" java.lang.OutOfMemoryError: Java heap space
    at java.util.concurrent.ConcurrentLinkedQueue.iterator(ConcurrentLinkedQueue.java:667)
    at org.apache.tomcat.util.net.JIoEndpoint$AsyncTimeout.run(JIoEndpoint.java:156)
    at java.lang.Thread.run(Thread.java:745)

I am getting above exception when I have put my app.war file in webapps path.


Solution

  • Increase the heap size is a must. You could create or edit the $CATALINA_HOME/bin/setenv.sh, add the line:

    JAVA_OPTS="-Xms1024m -Xmx2048m"
    

    And then restart tomcat. I think it is better to unpack the war file and copy it to $CATALINA_HOME/webapps, and furthermore, using hot-deploy in production is not a good idea.