Open Source Support Tools
 
Search Item
 
Summary
  Reported Issue
Title: [FILEUPLOAD-59] [fileupload] Memory Issue
Project: fileupload
Item Last Modified: Thu, 14 Aug 2008 02:35:33 -0700 (PDT)
Tags:  
 
 
Bug api application attached bytes case class commons created exception ext field fields file fileitem fileupload fileuploadbase fixed io issue memory multipart notice operating parameter parameters plain request servlet streaming string struts that type uploaded v1
Details
[FILEUPLOAD-59] [fileupload] Memory Issue
Reporter:   Vimil Saju
Created:   Wed, 12 Oct 2005 15:36:38 -0700 (PDT)
Updated:   Thu, 14 Aug 2008 02:35:33 -0700 (PDT)
Key:   FILEUPLOAD-59
Versions:   Not provided
Environment:   Operating System: All Platform: All
Priority:   3
Status:   Closed
Resolution:   Fixed
Original Link:   http://issues.apache.org/jira/browse/FILEUPLOAD-59
Summary:   [fileupload] Memory Issue
Description:
The reason for out of memory exception is that a FileItem object is created for
each request parameter whether it is file or an ordinary string parameter. the
FileItem object has a field of type DeferredFileStream which is initialized to
262144 bytes (256 Kb) so if there are around 1000 request parameters, around
256 MB of space will be required to hold the request parameters even though
most parameters may require only 8 to 10 bytes of memory for storage.
Comments:
martinc Sat, 29 Oct 2005 21:21:43 -0700 (PDT)
This was fixed some time ago in 1.1-dev.
kaifu Wed, 27 Jun 2007 19:22:28 -0700 (PDT)
I could not find any release related to this change in fileupload.
jochen Wed, 27 Jun 2007 23:06:19 -0700 (PDT)
Apart from possible changes, a streaming API was added in 1.2. If you are sensitive for memory considerations, this is the way to go anyways.
kaifu Wed, 27 Jun 2007 23:32:27 -0700 (PDT)
Since I am using Struts v1.1, when even there is multipart/form-data request, it use fileupload v1.0. I am not sure if I put fileupload v1.2 together with Struts v1.1, will they work.

I notice the code in fileupload v1.2 has changed FileUploadBase to use streaming, but will it save some memory for form fields in the case mentioned in this issue?

jochen Wed, 27 Jun 2007 23:39:40 -0700 (PDT)
I see absolutely no reason, why we should still support 1.1. This applies, in particular, to memory considerations and stuff like that. The streaming API was invented exactly for that purpose.
kaifu Thu, 28 Jun 2007 00:30:28 -0700 (PDT)
It looks like that fileupload v1.2 plus io v1.31 should solve the problem.
purushottam nawle Thu, 14 Aug 2008 02:32:42 -0700 (PDT)
Attached is the zip file containing a sample application using commons file upload. The lib directory contains a jar file named "commons-fileupload-ext.jar" resolves the out of memory problem. The new version of FileItem treats the plain text form parameters and multipart parameter in different ways. The newer version uses StringBuffer for the plain text parameters. This FileItem also supports ajax based monitoring of the file upload.
purushottam nawle Thu, 14 Aug 2008 02:35:33 -0700 (PDT)
Along with this the jar provides a base servlet class which does the file uploading. The user needs to extend this class to add just business logic such as implementing validation, process the uploaded file etc.