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

Pdf to image conversion not releasing memory after conversion

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Incomplete
    • Affects Version/s: 2.0.8
    • Fix Version/s: None
    • Component/s: Parsing, Rendering
    • Labels:
      None
    • Environment:
      Apache Tomcat/8.0.33, Linux, JDK 1.8
    • Flags:
      Important

      Description

      I have written a program that accepts pdf and convert it to image. Please see the below code for your reference.

      ByteArrayInputStream ipStream = new ByteArrayInputStream(document.getFile().getBytes());
      PDDocument documentUploaded = PDDocument.load(ipStream,MemoryUsageSetting.setupTempFileOnly());
                   
               documentUploaded.setResourceCache(new MyResourceCache());
      
      //Disabled a resource cache
      
      
               PDFRenderer pdfRenderer = new PDFRenderer(documentUploaded);
               int pageCounter = 0;
               for (PDPage page : documentUploaded.getPages())
               {         
                  BufferedImage bim = pdfRenderer.renderImageWithDPI(pageCounter, 300, ImageType.RGB);   
                   pageCounter = pageCounter + 1;
      
       
      
      // Some code here
      
                     bim.flush();
                     bim = null;
      
      
               }
               documentUploaded.close();
      
       
      

      After/Before conversion i printed heap size used by using Runtime.getRuntime().totalMemory() . Also I checked top command to see percentage of memory used.But in both cases the memory keeps increasing after each conversion and does not release used memory.After tomcat restart I get cleaned memory.

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                sachinm Sachin Mali
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: