Uploaded image for project: 'Commons FileUpload'
  1. Commons FileUpload
  2. FILEUPLOAD-94

Fileupload fails for forms with a large number of inputs

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0 Final
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: Linux
      Platform: PC

    • Bugzilla Id:
      24306

      Description

      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.

        Attachments

        1. ASF.LICENSE.NOT.GRANTED--fileupload-memory.patch
          2 kB
          Charles Oliver Nutter
        2. ASF.LICENSE.NOT.GRANTED--fileupload-patch
          8 kB
          Mike Samuel
        3. ASF.LICENSE.NOT.GRANTED--HDFileItemFactory.java
          3 kB
          Wolfgang Knauf
        4. ASF.LICENSE.NOT.GRANTED--TestServlet.java
          4 kB
          Mike Samuel

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mikesamuel@yahoo.com Mike Samuel
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: