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

Maruan Sahyoun commented on PDFBOX-4080:
----------------------------------------

What about keeping the implementation as is and use the {{ScratchFile}} within 
the apperance handlers. This will allow to manually pass the {{ScratchFile}}.

In addition we can change the objects so that the {{PDDocument}} or 
{{COSDocument}} or a config object (this way we could extend it later) is 
passed from top to bottom - Document, Page, Annotation ... - and kept in a 
member either with {{new PDPage}} and similar or when we do 
{{PDDocument.addPage}} and similar.

Then within the appearance handler we could check for the annotation if that is 
set. If yes and the ScratchFile hasn't been passed in the method call we could 
use that ScratchFile. If it hasn't been set we could then still use 
{{ScratchFile.getMainMemoryOnlyInstance()}}.

So the user creates PDFs adding the PDF Objects such as annotation or page to 
their parents *before* adding the content the user benefits from the improved 
memory. 

WDYT?

We also need to make sure that {{COSOutputStream}} actuall uses the 
{{ScratchFile}} for writing.

> Improve memory consumption of PDAbstractAppearanceHandler
> ---------------------------------------------------------
>
>                 Key: PDFBOX-4080
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4080
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDModel
>    Affects Versions: 3.0.0 PDFBox
>            Reporter: Maruan Sahyoun
>            Assignee: Maruan Sahyoun
>            Priority: Major
>              Labels: Annotations
>             Fix For: 3.0.0 PDFBox
>
>
> PDAbstractAppearanceHandler calls new COSStream(), this has a huge memory 
> footprint (PDFBOX-3868 and PDFBOX-3852). We'd need to find a way to pass the 
> document, or the document scratch file, or there will be trouble for files 
> with many annotations, e.g. a long scientific document with many footnotes.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to