HiAm Donnerstag, dem 04.11.2021 um 22:37 -0700 schrieb Kevin Day:
> Thanks for the analysis...
>
> So, how do we proceed? We are dealing with lots of different files
> from
> lots of different sources, so custom tuning maxedge makes me nervous.
>
>
> Is it worth trying BigBufferedImage? (I.e. would this even be
> accepted into
> the code base?) "Effective Handling of Big Images in Java"
> http://jobcardsystems.com/index.php/blog/29-effective-handling-of-big-images-in-java
> .
> - license is Creative Commons CCO. If licensing is a problem, then
> providing a hook to allow the BufferedImage creation to be overridden
> would
> be needed.
>
>
> Or should we be trying to profile to track down a memory leak?
IMHO we should try tracking down the leak or rule that out before
looking at an alternative to BufferedImage - if the leak is in PDFBox
we would still have the leak when using the replacement only kicking in
at a later stage.
BR
Maruan
>
> Awhile back, I dealt with native memory leaks in Java
> MappedByteBuffer
> under windows, but this was a native resource leak, and that doesn't
> seem
> like what we have here. And I don't know what the backing data store
> in
> ByteBuffer actually is.
>
> K
>
>
> On Thu, Nov 4, 2021, 9:52 PM Tilman Hausherr <thaush...@t-online.de>
> wrote:
>
> > Thanks for the files.
> >
> > I wonder if there is some memory leak, in PDFBox or in java itself.
> > The
> > H21 file has a pattern that contains an image (the company logo).
> > That
> > pattern has an XStep and YStep of 23438 although the image is 2148
> > x
> > 440. Because of a matrix scale of 0.0673396 the image pattern size
> > is
> > 1578 x 1578 at 72 dpi. So at 1200 dpi the size would be about 26300
> > x
> > 26300.
> >
> > You can limit this by setting pdfbox.rendering.tilingpaint.maxedge
> > to a
> > smaller value than the default of 3000. However this may have a bad
> > influence on other files.
> >
> > I tried to show the H21 file in PDFDebugger at 1000% which would be
> > 720
> > dpi. This worked until the last image. But no problem when
> > displaying
> > the last image first. That is why I suspect a memory leak. I
> > remember we
> > noticed something similar years ago, BufferedImage objects that
> > stayed
> > despite nobody using them.
> >
> > Tilman
> >
> > Am 02.11.2021 um 20:06 schrieb Kevin Day:
> > > Sorry it took so long to respond - I had to get permission to
> > > share
> > these.
> > >
> > > I did test with 2.0.24 and it did not help.
> > >
> > >
> > > Here are some files that cause the problem:
> > >
> > > https://github.com/trumpetinc/boottest/blob/main/JrachvUniverse_H21.pdf
> > >
> > https://github.com/trumpetinc/boottest/blob/main/PP%20Opera%20Building_A53.pdf
> > >
> > >
> > > Here is some quick code that demonstrates the problem (update for
> > > your
> > > printer name and PDF path):
> > >
> > >
> > https://github.com/trumpetinc/boottest/blob/main/SimplifiedPdfBoxPdfPrinter.java
> > >
> > >
> > >
> > > Maybe in TilingPaint#getImage(PageDrawer, PDTilingPattern,
> > > PDColorSpace,
> > > PDColor, AffineTransform, Rectangle2D), the BufferedImage could
> > > benefit from something similar to BigBufferedImage described in
> > > this
> > post?
> > > (
> > >
> > https://stackoverflow.com/questions/3854200/why-does-a-bufferedimage-require-so-much-memory-beyond-the-size-of-its-data-arra
> > > ). Or maybe there is something in the scaling logic?
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Thu, Oct 28, 2021 at 11:12 AM Tilman Hausherr
> > > <thaush...@t-online.de>
> > > wrote:
> > >
> > > > Huge buffered images can happen in patterns if the pattern
> > > > matrix and/or
> > > > the current transformation matrix result in a huge scale.
> > > >
> > > > You could retry with 2.0.24, but I'm pessimistic. Please share
> > > > the PDF
> > > > (upload to a sharehoster).
> > > >
> > > > Tilman
> > > >
> > > > Am 28.10.2021 um 01:17 schrieb Kevin Day:
> > > > > Using PDFBox 2.0.20
> > > > >
> > > > > We use the following to print the PDF:
> > > > >
> > > > > HashPrintRequestAttributeSet attributes = new
> > > > > HashPrintRequestAttributeSet();
> > > > >
> > > > > try(PDDocument doc = PDDocument.load(pdf,
> > > > > MemoryUsageSetting.setupMixed(5000000L))){
> > > > > job.setPageable(new PDFPageable(doc));
> > > > > job.print(attributes);
> > > > > }
> > > > >
> > > > > This works really well for thousands of PDFs, but we've run
> > > > > into one
> > > > > particular PDF that causes an OutOfMemoryException.
> > > > >
> > > > >
> > > > > The problem PDF is rendered (does not contain bitmaps).
> > > > >
> > > > > I've provided a huge amount of heap (over 1GB now), and it is
> > > > > still
> > > > failing.
> > > > > As near as I can tell from the stack trace (which I'll
> > > > > include below),
> > it
> > > > > seems like the problem is with creation of a huge buffered
> > > > > image.
> > > > >
> > > > > The physical page size in the PDF is 8.5 x 11".
> > > > >
> > > > > The PDFPrintable is configured as follows:
> > > > >
> > > > > Scaling is ACTUAL_SIZE
> > > > > dpi is 0.0
> > > > > subsamplingAllowed is false
> > > > > renderingHints is null
> > > > >
> > > > >
> > > > > Here is the stack trace:
> > > > >
> > > > > java.lang.OutOfMemoryError: Java heap space
> > > > > at
> > > > java.desktop/java.awt.image.DataBufferInt.<init>(DataBufferInt.
> > > > java:75)
> > > > > at
> > java.desktop/java.awt.image.Raster.createPackedRaster(Raster.java:4
> > 67)
> > > > > at
> > > > >
> > > >
> > java.desktop/java.awt.image.DirectColorModel.createCompatibleWritab
> > leRaster(DirectColorModel.java:1032)
> > > > > at
> > > > java.desktop/java.awt.image.BufferedImage.<init>(BufferedImage.
> > > > java:333)
> > > > > at
> > org.apache.pdfbox.rendering.TilingPaint.getImage(TilingPaint.java:1
> > 43)
> > > > > at
> > > > > org.apache.pdfbox.rendering.TilingPaint.<init>(TilingPaint.ja
> > > > > va:103)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.rendering.TilingPaintFactory.create(TilingPaintFa
> > ctory.java:60)
> > > > > at
> > > > > org.apache.pdfbox.rendering.PageDrawer.getPaint(PageDrawer.ja
> > > > > va:351)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.rendering.PageDrawer.getNonStrokingPaint(PageDraw
> > er.java:719)
> > > > > at
> > > > > org.apache.pdfbox.rendering.PageDrawer.fillPath(PageDrawer.ja
> > > > > va:819)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.contentstream.operator.graphics.FillEvenOddRule.p
> > rocess(FillEvenOddRule.java:37)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDF
> > StreamEngine.java:932)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperat
> > ors(PDFStreamEngine.java:510)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFSt
> > reamEngine.java:484)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.contentstream.PDFStreamEngine.showForm(PDFStreamE
> > ngine.java:187)
> > > > > at
> > org.apache.pdfbox.rendering.PageDrawer.showForm(PageDrawer.java:146
> > 2)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.contentstream.operator.graphics.DrawObject.proces
> > s(DrawObject.java:86)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDF
> > StreamEngine.java:932)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperat
> > ors(PDFStreamEngine.java:510)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFSt
> > reamEngine.java:484)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStre
> > amEngine.java:156)
> > > > > at
> > > > > org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.ja
> > > > > va:271)
> > > > > at
> > > > >
> > > >
> > org.apache.pdfbox.rendering.PDFRenderer.renderPageToGraphics(PDFRen
> > derer.java:431)
> > > > > at
> > > > > org.apache.pdfbox.printing.PDFPrintable.print(PDFPrintable.ja
> > > > > va:246)
> > > > > at
> > > > >
> > > >
> > java.desktop/sun.print.RasterPrinterJob.printPage(RasterPrinterJob.
> > java:2430)
> > > > > at
> > > >
> > java.desktop/sun.print.RasterPrinterJob.print(RasterPrinterJob.java
> > :1654)
> > > > >
> > > > >
> > > > > Next, I tried setting subsampling to true - this made no
> > > > > difference.
> > > > >
> > > > >
> > > > > Next, I tried hard coding the dpi to 300f - this works with
> > > > > no
> > problems.
> > > > >
> > > > >
> > > > > Next, I tried hard coding the dpi to 600f - this does not
> > > > > throw the
> > heap
> > > > > space error - but with strange results:
> > > > > - I see "java.lang.OutOfMemoryError" on sys.err - it does NOT
> > > > > throw an
> > > > > exception
> > > > > - The pages come off the printer as blank pages
> > > > >
> > > > >
> > > > > Does anyone have any suggestions on how we can print using
> > > > > the
> > printer's
> > > > > full resolution?
> > > > >
> > > > > Thanks!
> > > > >
> > > >
> > > > ---------------------------------------------------------------
> > > > ------
> > > > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> > > > For additional commands, e-mail: users-h...@pdfbox.apache.org
> > > >
> > > >
> >
> >
> > -------------------------------------------------------------------
> > --
> > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> > For additional commands, e-mail: users-h...@pdfbox.apache.org
> >
> >
--
--
Maruan Sahyoun
FileAffairs GmbH
Josef-Schappe-Straße 21
40882 Ratingen
Tel: +49 (2102) 89497 88
Fax: +49 (2102) 89497 91
sahy...@fileaffairs.de
www.fileaffairs.de
Geschäftsführer: Maruan Sahyoun
Handelsregister: AG Düsseldorf, HRB 53837
UST.-ID: DE248275827
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org