You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2003/10/31 21:59:35 UTC

DO NOT REPLY [Bug 24306] New: - Fileupload fails for forms with a large number of inputs

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24306>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24306

Fileupload fails for forms with a large number of inputs

           Summary: Fileupload fails for forms with a large number of inputs
           Product: Commons
           Version: 1.0 Final
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: File Upload
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: MikeSamuel@yahoo.com


Attached is a test case servlet which repeats the problem with the Jun 24, 2003
fileupload-1.0 release.

FileUploadBase.parseRequest runs out of memory when parsing a form with a large
number of inputs.  The cause seems to be DeferredFileOutputStream which
allocates a ByteArrayOutputStream per input, each of which preallocates a buffer
of length inMemoryThreshold.  The in memory threshold defaults to 10k, but if it
is made larger (> 1 M in our environment), then the vm quickly runs out of
memory.  Most of this memory is wasted since most files are ~5k, and almost all
non-file inputs are less than 1k.

I patched DeferredFileOutputStream to use a different underlying in memory
stream.  I don't really know why ByteArrayOutputStream uses a single byte[],
since you can't do random access on the underlying buffer anyway.
I think the patch is something that could be incorporated into the default file
upload implementation without any noticable change in performance.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org