You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Dhaval Vekaria <dh...@hotmail.com> on 2020/01/01 09:54:55 UTC

Java Heap Space Issue

Hi,

I am using pdfbox library version 2.0.17 and attaching/embedding files to pdf. The problem is while attaching large files, it give java heap space issue.

Attache files(i. e. docs) size are 300mb, 400mb and 500mb.

Sample code link: https://drive.google.com/open?id=1fOJHvZN_9M8CnS-0aQOtFxQ5Xzg2DMng

Note: Above static class able to generate the PDF with attachments but same code is not working in web application.

Web Application running with 2GB heap space parameter.

Could some one help me out for the issue.

Regards,
Dhaval

Re: Java Heap Space Issue

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,
Try using "MemoryUsageSetting.setupTempFileOnly()" as 2nd parameter when 
loading your document.
And you can slightly lessen the memory footprint by not using "data". 
Just pass a FileInputStream to PDEmbeddedFile(). This is poorly 
documented / there is a javadoc bug - the input stream is closed.
Tilman
PS: I wrote a comment in your SO question.

Am 01.01.2020 um 10:54 schrieb Dhaval Vekaria:
> Hi,
>
> I am using pdfbox library version 2.0.17 and attaching/embedding files to pdf. The problem is while attaching large files, it give java heap space issue.
>
> Attache files(i. e. docs) size are 300mb, 400mb and 500mb.
>
> Sample code link: https://drive.google.com/open?id=1fOJHvZN_9M8CnS-0aQOtFxQ5Xzg2DMng
>
> Note: Above static class able to generate the PDF with attachments but same code is not working in web application.
>
> Web Application running with 2GB heap space parameter.
>
> Could some one help me out for the issue.
>
> Regards,
> Dhaval
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org