2

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?

2
  • Set a higher heap size on startup may fix you problem. Commented Jul 12, 2012 at 7:00
  • One of the numerous answers about how to set the java heap space in tomcat : serverfault.com/questions/139435/… Commented Jul 12, 2012 at 7:01

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

3 Comments

@Vijay here's a link to setting the Xmx paramter. As to reading the file in chunks, how do you currently read the file?
actually i have setup BIM SERVER and they provided the WAR file for deployment. So don't know how they are reading files. but i did change the heap size using -Xmx attribute but still it is not working.
Increasing the heap size will not be useful -- go talk to the "BIM SERVER" folks and ask about their file-upload requirements. You could also configure your server to do a heap dump on OOME so you can look at what it taking up all the space: probably a huge byte array with the file's contents. If so, "BIM SERVER" is poorly-written.
4

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 "

Windows:

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

set CATALINA_OPTS=-server -Xms256m -Xmx1024m 

Restart the tomcat after above change.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.