• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to resolve OutOfMemoryError

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my scenario:-

I am trying to upload a large file using applet with servlet.
Please confirm me!!.. is it possible to upload more than 2GB file from applet to servelt using I/O streams by this scenario.I am reading a file in java using I/O stream classes and writing the above streams to servlet by creating connection to it.In servlet,i am writing the above streams to file. If i try to write more than 1GB files, i am getting OutOfMemoryError.To increase the heap size can we avoid this error . If so, where should i increase in Tomcat server? please help me to resolve this issue.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use a simple html page to upload a 1G file to a struts 2 application deployed in Tomcat. It works even if Tomcat is configured with heap size up to 64M.

I think there should be a misuse of memory in your servlet code. I suggest that you replace your code on file uploading with "commons fileupload" that is the default for uploading in struts 2.
 
elay Raja
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry,i already tried with apache commons upload library in servlet but currently none of the browser will not support to upload more than 2GB files except IIS webServer. So we decided to do with applet & Servlet.Moreover we are not using Struts also.I want to know how to increase the heap size in java. Because i had written code using I/O streams to write file from applet2Servlet.When i try to write more than 1GB then my JVM throws OutOfMemoryError.I tried to set heap size in environment variable like this..

Variable: _JAVA_OPTIONS
Value:-Xmx1024m
But I'm geeting Java Plug in Fatal Error like this :-Several Java Virtual Machines running in same process caused an error.
please help me how to increase the heap size for java.. we are not using ant build also. Please help me to resolve this issue.Our requirement is to upload minimum 4GB file.
[ June 20, 2008: Message edited by: elay Raja ]
 
samuel tsai
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, 2G size limit does exist in browsers including Firefox and IE. So you have choice between applet and ActiveX. But why need so much memory in applet? It would be better off if you transfer file to server part by part. You can publish a web service in server to receive file part. Each time reading a part of file, applet invokes the web service with the part. Repeat until transfer is done. Moreover you can implement a resumable file transfer if more efforts.
[ June 21, 2008: Message edited by: samuel tsai ]
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by elay Raja:
This is my scenario:-

I am trying to upload a large file using applet with servlet.
Please confirm me!!.. is it possible to upload more than 2GB file from applet to servelt using I/O streams by this scenario.I am reading a file in java using I/O stream classes and writing the above streams to servlet by creating connection to it.In servlet,i am writing the above streams to file. If i try to write more than 1GB files, i am getting OutOfMemoryError.To increase the heap size can we avoid this error . If so, where should i increase in Tomcat server? please help me to resolve this issue.



In my thinking, the random access memory (RAM)is small, say less or equal to 1GB. So the Java Virtual Machine could not allocate enough memory to write files more than 1GB.

Errors occur in Java when an event during the execution of your code could not be handled by the Java Virtual Machine (JVM).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic