[ 
https://issues.apache.org/jira/browse/PDFBOX-3808?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sergei Ovchinnikov updated PDFBOX-3808:
---------------------------------------
    Affects Version/s: 2.0.6
        Fix Version/s: 2.0.7

> Strange memory behavior on load PDDocument
> ------------------------------------------
>
>                 Key: PDFBOX-3808
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3808
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.6
>            Reporter: Sergei Ovchinnikov
>             Fix For: 2.0.7
>
>         Attachments: out2.pdf
>
>
>  It takes ~600mb of memory after loading a single page document (with embeded 
> fonts). Memory usage grows slightly with the increasing number of pages in 
> the document. What's wrong with this PDF (I've not noticed strange patterns 
> in PDF debugger) ?
> {code}
>     public static void main(String[] args) throws Exception {
>         File in = new File("out2.pdf");
>         File out = new File("out2_.pdf");
>         if (!out.exists()) {
>             out.createNewFile();
>         }
>         InputStream inputStream = null;
>         OutputStream outputStream = null;
>         System.out.println("start pdf 2 pdf");
>         PDDocument doc = null;
>         try {
>             final long startTime = System.currentTimeMillis();
>             inputStream = new BufferedInputStream(new FileInputStream(in));
>             outputStream = new BufferedOutputStream(new 
> FileOutputStream(out));
>             System.out.println(MessageFormat.format("before loading 
> totalMemory: {0}, free: {1}, max: {2}",
>                     Runtime.getRuntime().totalMemory(),
>                     Runtime.getRuntime().freeMemory(),
>                     Runtime.getRuntime().maxMemory()));
>             doc = PDDocument.load(inputStream, 
> MemoryUsageSetting.setupTempFileOnly());
>             System.out.println(MessageFormat.format("after loading 
> totalMemory: {0}, free: {1}, max: {2}",
>                     Runtime.getRuntime().totalMemory(),
>                     Runtime.getRuntime().freeMemory(),
>                     Runtime.getRuntime().maxMemory()));
>             System.out.println("save");
>             doc.save(outputStream);
>             final long endTime = System.currentTimeMillis();
>             System.out.println(MessageFormat.format("it takes 
> {0,number,#.###} s to handle pdf 2 pdf ",
>                     (endTime - startTime) / 1000.));
>         } finally {
>             try {
>                 if (doc != null) {
>                     doc.close();
>                 }
>             } finally {
>                 IOUtils.closeQuietly(inputStream);
>                 IOUtils.closeQuietly(outputStream);
>             }
>         }
>         System.out.println("ok");
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to