Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4167

OutOfMemoryError on FlateFilter - Deflater.end() is missing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.8, 2.0.9
    • 2.0.10, 3.0.0 PDFBox
    • Writing
    • None
    • Windows 7 x64, Java 8 SE

    Description

      While creating some large PDF documents by PDFBox 2.0.8 and 2.0.9, I met an OutOfMemoryError on FlateFilter.encode().
      While creating some small PDF documents, there are no problems.

      I checked the source code of org.apache.pdfbox.filter.FlateFilter.java, and I found that calling of Deflater.end() method is missing.

      When DeflaterOutputStream object is created by the 'new DeflaterOutputStream(encoded,deflater)' constructor method (i.e. 'custom deflater' is given),
      DeflaterOutputStream.close() API does not call 'deflater.end()' method automatically.
      Deflater.end() method may be called by the finalizer at GC, of cource, but the timing of GC is undecidable by user. So 'deflater.end()' method should be called explicitly. Otherwise it may cause an OutOfMemoryError.

      Attachments

        Activity

          People

            tilman Tilman Hausherr
            mew MINAKAMI Hiroki
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: