Issue Details (XML | Word | Printable)

Key: FILEUPLOAD-59
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Vimil Saju
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Commons FileUpload

[fileupload] Memory Issue

Created: 12/Oct/05 10:36 PM   Updated: 16/Dec/08 11:21 AM
Return to search
Component/s: None
Affects Version/s: 1.0 Final
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Zip Archive Licensed for inclusion in ASF works UploadTest.zip 2008-08-14 09:32 AM Purushottam M. Nawle 312 kB
Environment:
Operating System: All
Platform: All

Bugzilla Id: 37042


 Description  « Hide
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.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Martin Cooper added a comment - 30/Oct/05 04:21 AM
This was fixed some time ago in 1.1-dev.

Felix K F Chan added a comment - 28/Jun/07 02:22 AM
I could not find any release related to this change in fileupload.

Jochen Wiedmann added a comment - 28/Jun/07 06:06 AM
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.

Felix K F Chan added a comment - 28/Jun/07 06:32 AM
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 Wiedmann added a comment - 28/Jun/07 06:39 AM
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.

Felix K F Chan added a comment - 28/Jun/07 07:30 AM
It looks like that fileupload v1.2 plus io v1.31 should solve the problem.

Purushottam M. Nawle added a comment - 14/Aug/08 09:32 AM
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 M. Nawle added a comment - 14/Aug/08 09:35 AM
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.

vaishali dolas added a comment - 16/Dec/08 10:51 AM
I'm using the jar which are given in above zip.When i'm trying to run the same application in struts2 its giving problem for small file upload.
If file size is small it not uploading.

Jochen Wiedmann added a comment - 16/Dec/08 11:21 AM
Please don't use this bug tracker for support requests. Your best bet seems to be the Struts users mailing list.

Apart from that, your problem might be related to FILEUPLOAD-138. If so, it should be fixed by upgrading to fileupload 1.2.1.