commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31728] New: - unexpected memory usage on fileupload
Date Fri, 15 Oct 2004 12:16:10 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31728>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31728

unexpected memory usage on fileupload

           Summary: unexpected memory usage on fileupload
           Product: Commons
           Version: 1.0 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: File Upload
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: ahaufler@gmx.de


In my eyes this is kind of unexpected behavoir:

The FileUpload component reserves an byte[] which is "maxThreshold" large, for 
every request item, even it is a form field, and even if the sent data is lots 
smaller. This is kind of unexpected, as I though the maxThreshold parameter 
simply deciedes whether uploaded files should stay in memory or not.

The "bug" can be found in DeferedFileOutputstream.java:
(lines 126-133):
    public DeferredFileOutputStream(int threshold, File outputFile)
    {
        super(threshold);
        this.outputFile = outputFile;

(131)   memoryOutputStream = new ByteArrayOutputStream(threshold);
        currentOutputStream = memoryOutputStream;
    }

In line 131, the ByteArrayOutputStream allocates an byte[threshold] for every 
item no matter how large it is. I think this could be (should be)  changed to 
a lots smaller constant value, because the given size is just the initial 
size, so the byte[] the stream writes on, can still grow on demand, and the 
maxThreshold parameter can still be used to determine if a file should be 
written to memory, or to disk.

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


Mime
View raw message