You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2017/05/25 16:20:04 UTC

[jira] [Commented] (PDFBOX-3808) Strange memory behavior on load PDDocument

    [ https://issues.apache.org/jira/browse/PDFBOX-3808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16024952#comment-16024952 ] 

Tilman Hausherr commented on PDFBOX-3808:
-----------------------------------------

You could save space by opening the file as a file and not as a stream. I'm able to render the file with -Xmx350m and I did not even use {{MemoryUsageSetting.setupTempFileOnly()}}. I don't see anything "wrong" with the PDF. It has a 200dpi scan and lots of fonts.

> 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
>         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: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org