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 2004/10/15 14:16:10 UTC

DO NOT REPLY [Bug 31728] New: - unexpected memory usage on fileupload

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