2017  Kodetalk | Feedback | Privacy Policy | Terms | About

Java Heap Space Error in tomcat

I am using Tomcat 7.0.28. I have deployed a war file. In this war file there is a server like structure where we can upload the files.

Now when i access that web page it is working, but when i try to upload the large files it is showing error of JAVA Heap Space.

How can i solve it?


You are probably trying to put the whole file in memory. Your first shot should be to change the -Xmx parameter at the Tomcat JVM startup options to give it more memor. Aside from that, you'll have to read the file one chunk at a time, and write it on the hard drive, so as to free the memory.

Or Else you can increase HeapSize in tomcat using below command .

Linux : Open Catalina.sh file placed in the "bin" directory. You have to apply the changes to this line

CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m "


Open the "Catalina.bat" file placed in the "bin" directory

set CATALINA_OPTS=-server -Xms256m -Xmx1024m 

Restart the tomcat after above change.

Answer is