Re: Guidance on heap space error when printing document

2021-11-11 Thread Tilman Hausherr
Am 07.11.2021 um 15:53 schrieb Tilman Hausherr: I tried it and it works pretty fast. The memory leak is still there but it comes later. The memory leak was in PDFDebugger and it's now mostly fixed https://issues.apache.org/jira/browse/PDFBOX-5320 So I've worked in the wrong direction. I've

Re: Guidance on heap space error when printing document

2021-11-08 Thread Kevin Day
Fair enough. All of the proposed changes are very self contained. Feel free to reach out directly if you have any questions when you do get time. I'm happy to be a sounding board of you want to retry the scaling approach (instead of hard cropping), or want to discuss raster generation during prin

Re: Guidance on heap space error when printing document

2021-11-08 Thread Tilman Hausherr
Am 08.11.2021 um 14:28 schrieb Kevin Day: Will you accept my code changes to have different maxedge values for 32 bit vs 64 bit? It's fine to have different initializations. We have code that works differently depending on the JDK version. But we're not there yet. What I want to do is to sep

Re: Guidance on heap space error when printing document

2021-11-08 Thread Kevin Day
Will you accept my code changes to have different maxedge values for 32 bit vs 64 bit? On Mon, Nov 8, 2021, 12:51 AM Tilman Hausherr wrote: > Am 08.11.2021 um 06:38 schrieb Kevin Day: > > I just realized what MAXEDGE does. > > > > You are basically saying that the raster can't be bigger than MA

Re: Guidance on heap space error when printing document

2021-11-08 Thread Kevin Day
To really fix the printing performance, I think you will need to either: 1. The drawer needs to have a viewport concept that filters content stream operators better they render. I don't know if this is even possible or reasonable. I would have thought that sharing like this would suggest be implem

Re: Guidance on heap space error when printing document

2021-11-07 Thread Tilman Hausherr
Am 08.11.2021 um 06:38 schrieb Kevin Day: I just realized what MAXEDGE does. You are basically saying that the raster can't be bigger than MAXEDGE x MAXEDGE, and if it is, then you clamp the dimensions. But - are you scaling the bitmap? Or are you just cropping it? If you are just cropping it

Re: Guidance on heap space error when printing document

2021-11-07 Thread Tilman Hausherr
Am 08.11.2021 um 06:03 schrieb Kevin Day: But that's only with a single render. Because printing can involve rendering many times for banded printing (on my test device, I am seeing well over 100 bands when printing this sample file), the page level caching should be substantial (the rendering o

Re: Guidance on heap space error when printing document

2021-11-07 Thread Kevin Day
I just realized what MAXEDGE does. You are basically saying that the raster can't be bigger than MAXEDGE x MAXEDGE, and if it is, then you clamp the dimensions. But - are you scaling the bitmap? Or are you just cropping it? If you are just cropping it, it seems like a better approach would be t

Re: Guidance on heap space error when printing document

2021-11-07 Thread Kevin Day
Test procedure: Open PdfBox Debugger, load PDF, capture render time from label in lower left corner of window. With PdfBox 2.0.17 - this PDF renders in about 4.8 seconds (but is missing the colored pattern). With PdfBox 3 baseline (no code changes) - this PDF renders in 16.2 seconds seconds. W

Re: Guidance on heap space error when printing document

2021-11-07 Thread Tilman Hausherr
Hi, I don't have much time right now, but please test your change with the file from https://issues.apache.org/jira/browse/PDFBOX-3688 Tilman - To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional comm

Re: Guidance on heap space error when printing document

2021-11-07 Thread Kevin Day
Another thought: As I've worked with the code, I think that maybe one possible issue is that TilingPaint is creating its image during construction. Would it be better if TilingPaint constructed an image on demand in createContext()? That way you would have full information about the clipping reg

Re: Guidance on heap space error when printing document

2021-11-07 Thread Kevin Day
oh - I see a major problem (it's a bit of a reverse memory leak, actually) that is involved in your disk space issue (it also results in really poor performance for image tiling operations): The cache in TilingPaintFactory is based on WeakHashMap. WeakHashMap is designed around weak referenced *

Re: Guidance on heap space error when printing document

2021-11-07 Thread Kevin Day
Ah yes - the file deletion in BigBufferedImage only happens during finalize() (or with a shutdown hook). That's why you are blowing out your disk space. We will have the same problem even if we use ScratchFile. This means that we have to talk about disposing the BufferedImage instances - but Buf

Re: Guidance on heap space error when printing document

2021-11-07 Thread Kevin Day
There is another issue with BigBufferedImage - it does not work well on 32 bit JVMs. The problem is that it creates a single MappedByteBuffer for the entire size of a channel's data (for the problem file, this means that each buffer has 172,975,104 bytes). I think it would be better to create a D

Re: Guidance on heap space error when printing document

2021-11-07 Thread Tilman Hausherr
Am 07.11.2021 um 16:09 schrieb Kevin Day: ok - I think that maybe there are two things going on, then. The first is that we are allocating a single buffer that is bigger than the default heap (700MB > 500MB). I really think that the only two solutions are to move this off the heap or reduce the

Re: Guidance on heap space error when printing document

2021-11-07 Thread Kevin Day
PS - PdfBox already has the sun.* stuff in it - see IOUtils::unmapper() Kevin Day *trumpet**p| *480.961.6003 x1002 *e| *ke...@trumpetinc.com www.trumpetinc.com LinkedIn | Trumpet Blog | Twitter <

Re: Guidance on heap space error when printing document

2021-11-07 Thread Kevin Day
ok - I think that maybe there are two things going on, then. The first is that we are allocating a single buffer that is bigger than the default heap (700MB > 500MB). I really think that the only two solutions are to move this off the heap or reduce the size of the allocation. Then the second iss

Re: Guidance on heap space error when printing document

2021-11-07 Thread Tilman Hausherr
I tried it and it works pretty fast. The memory leak is still there but it comes later. Other drawbacks arethat it doesn't clean up after itself fast enough, and it uses a sun.* class. Tilman Am 07.11.2021 um 14:31 schrieb Tilman Hausherr: Am 05.11.2021 um 22:09 schrieb Kevin Day: ok - so s

Re: Guidance on heap space error when printing document

2021-11-07 Thread Tilman Hausherr
Am 05.11.2021 um 22:09 schrieb Kevin Day: ok - so should we be clamping the xstep in some way? Or at this depth of the algorithm do we not have enough context to actually tell that it will be outside the page/clipping region? Yes + yes, that is the problem. The context would have to include th

Re: Guidance on heap space error when printing document

2021-11-05 Thread Kevin Day
ok - so should we be clamping the xstep in some way? Or at this depth of the algorithm do we not have enough context to actually tell that it will be outside the page/clipping region? I'm beginning to think that the BigBufferedImage might be the right solution... This is very inefficient, but h

Re: Guidance on heap space error when printing document

2021-11-05 Thread Tilman Hausherr
Am 05.11.2021 um 20:38 schrieb Kevin Day: I do have a bit of experience with memory leaks (side effect of writing high performance java code, unfortunately!) I am pretty sure that this is not a memory leak, though. If this was a memory leak, we would see calls happening multiple times before f

Re: Guidance on heap space error when printing document

2021-11-05 Thread Kevin Day
I do have a bit of experience with memory leaks (side effect of writing high performance java code, unfortunately!) I am pretty sure that this is not a memory leak, though. If this was a memory leak, we would see calls happening multiple times before failure. The failure happens on the very fir

Re: Guidance on heap space error when printing document

2021-11-05 Thread Tilman Hausherr
If you're experienced with memory leaks then it would be nice if you could search. Things I tried that didn't help: - calling graphics.setPaint(null) after operations (to "lose" TilingPaint objects) - disabling the (weak) cache of TilingPaint objects - adding finalize to see if the TilingPaint

Re: Guidance on heap space error when printing document

2021-11-05 Thread sahy...@fileaffairs.de
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.

Re: Guidance on heap space error when printing document

2021-11-04 Thread 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 i

Re: Guidance on heap space error when printing document

2021-11-04 Thread Tilman Hausherr
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 patter

Re: Guidance on heap space error when printing document

2021-11-02 Thread 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%

Re: Guidance on heap space error when printing document

2021-10-28 Thread Tilman Hausherr
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

Guidance on heap space error when printing document

2021-10-27 Thread 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(500L))){ job.setPageable(new PDFPageable(doc)); job.print(a