aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes how  to resolve OutOfMemoryError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "how  to resolve OutOfMemoryError " Watch "how  to resolve OutOfMemoryError " New topic
Author

how to resolve OutOfMemoryError

elay Raja
Greenhorn

Joined: Jun 10, 2008
Posts: 27
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.
samuel tsai
Greenhorn

Joined: Jun 16, 2008
Posts: 2
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

Joined: Jun 10, 2008
Posts: 27
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

Joined: Jun 16, 2008
Posts: 2
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 ]
Udegbunam Morah
Ranch Hand

Joined: Oct 13, 2002
Posts: 36
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).


Udegbunam Ikechukwu Morah<br />B.Sc.,SCJP, MCP, OCP, PMP<br />Manager, Business COnsulting Group<br />Deep Business Solutions Limited
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to resolve OutOfMemoryError