wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Increase JVM Heap size in Tomcat 6.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Increase JVM Heap size in Tomcat 6.0" Watch "Increase JVM Heap size in Tomcat 6.0" New topic
Author

Increase JVM Heap size in Tomcat 6.0

Vijay Kumar Raman
Greenhorn

Joined: Oct 19, 2010
Posts: 12
Hi,
I need to increase JVM Heap size in Tomcat 6.0 to 100MB. I am running a web application in Tomcat6 using whcih I should upload and download file attachments of size upto 100MB.
I start Tomcat6 from the console mode. i.e, D:\Program Files\Apache Software Foundation\Tomcat 6.0\bin>tomcat6.exe.
I tried increasing heap size from command prompt by setting hte environment variables CATALINA_OPT and JAVA_OPT. it didnt help either. please help. Tomcat is not running as a windows service in my PC either.
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Hope this will help.


Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

Adding RAM to the JVM may not help. Typically files are uploaded to a temporary filesystem location and you are given access to the uploaded data without the need for the entirety of the uploaded data to ever exist simultaneously in RAM.

Likewise, when presenting large files to the client, it's more efficient to use a buffered data copy process than to load all the data to be downloaded into RAM and then copy the RAM to the HttpResponse outputstream.

However, as far as JVM tuning goes, you can define a JAVA_OPTS environment-setting statement and place it in a file named TOMCAT_HOME/bin/setenv.bat (setenv.sh for Linux/Unix).


Customer surveys are for companies who didn't pay proper attention to begin with.
Vijay Kumar Raman
Greenhorn

Joined: Oct 19, 2010
Posts: 12
I tried modifiying the JAVA_OPT and CATALINA_OPT environment variable's values to 1GB but still getting the same exception "outofmemoryerror". I believe my current approach which reads the whole file from FileInputStream and stores it in a byte[] array and finally storing the byte[] array to the database is giving problem since it requires the whole file should be stored in memory before persisiting into database. Is there any approach in hibernate 3.0 to store large files in database and without ctoring them in memory (RAM).

I need alternative solution to modify my application code to handle large files rather than modifying the application server environment variables values since my application will be deployed in different application servers.

Thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

You wouldn't really want to store that much data in RAM, since it would basically only work for a very small number of users if it worked at all.

I think you can probably setup a mechanism whereby the cached incoming input is streamed directly into the Hibernate BLOB, but you're better off asking about that in the Hibernate forum. There would be no essential difference just because you were doing it in a webapp.
Vijay Kumar Raman
Greenhorn

Joined: Oct 19, 2010
Posts: 12
Thanks for the clarification. I will post my query in hibernate OR mapping forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Increase JVM Heap size in Tomcat 6.0
 
Similar Threads
Jvm Memory
OutOfMemory Error
java.lang.OutOfMemoryError
Analyse large heap dump file
how to increase/decrease the heap size in java in windows