You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "lanshiqin (Jira)" <ji...@apache.org> on 2021/06/17 10:38:00 UTC
[jira] [Updated] (PDFBOX-5218) PDF to Image, Why is the larger the
heap memory setting, the larger the parsing footprint
[ https://issues.apache.org/jira/browse/PDFBOX-5218?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
lanshiqin updated PDFBOX-5218:
------------------------------
Description:
Why is the larger the heap memory setting, the larger the parsing footprint
-Xmx8g, Use 4g at most
-Xmx1g, Use 600MB at most
It is bug?
[PDF File|https://gitee.com/lanshiqin/web-demo/raw/master/src/main/resources/static/Max_PDF_DEMO.pdf]
{code:java}
public class Demo {
public static void main(String[] args) throws Exception {
String pdfUrl = "file:///D:\\xxxx.pdf";
InputStream in = new URL(pdfUrl).openStream();
PDDocument document = PDDocument.load(in, MemoryUsageSetting.setupTempFileOnly());
document.setResourceCache(null);
PDFRenderer renderer = new PDFRenderer(document);
renderer.setSubsamplingAllowed(true);
for (int i = 0; i < document.getNumberOfPages(); i++) {
BufferedImage bufferedImage = renderer.renderImageWithDPI(i, 100);
try {
System.out.println("current is : " + i);
} finally {
bufferedImage.getGraphics().dispose();
}
}
document.close();
in.close();
}
}
{code}
was:
Why is the larger the heap memory setting, the larger the parsing footprint
-Xmx8g, Use 4g at most
-Xmx1g, Use 600MB at most
It is bug?
[PDF File|https://gitee.com/lanshiqin/web-demo/raw/master/src/main/resources/static/Max_PDF_DEMO.pdf]
> PDF to Image, Why is the larger the heap memory setting, the larger the parsing footprint
> -----------------------------------------------------------------------------------------
>
> Key: PDFBOX-5218
> URL: https://issues.apache.org/jira/browse/PDFBOX-5218
> Project: PDFBox
> Issue Type: Improvement
> Affects Versions: 2.0.24
> Environment: jdk1.8
> windows 10
> linux
> macOS
> Reporter: lanshiqin
> Priority: Major
>
> Why is the larger the heap memory setting, the larger the parsing footprint
> -Xmx8g, Use 4g at most
> -Xmx1g, Use 600MB at most
> It is bug?
> [PDF File|https://gitee.com/lanshiqin/web-demo/raw/master/src/main/resources/static/Max_PDF_DEMO.pdf]
>
>
> {code:java}
> public class Demo {
> public static void main(String[] args) throws Exception {
> String pdfUrl = "file:///D:\\xxxx.pdf";
> InputStream in = new URL(pdfUrl).openStream();
> PDDocument document = PDDocument.load(in, MemoryUsageSetting.setupTempFileOnly());
> document.setResourceCache(null);
> PDFRenderer renderer = new PDFRenderer(document);
> renderer.setSubsamplingAllowed(true);
> for (int i = 0; i < document.getNumberOfPages(); i++) {
> BufferedImage bufferedImage = renderer.renderImageWithDPI(i, 100);
> try {
> System.out.println("current is : " + i);
> } finally {
> bufferedImage.getGraphics().dispose();
> }
> }
> document.close();
> in.close();
> }
> }
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org