java.lang.OutOfMemoryError: Java heap space

273 views
Skip to first unread message

Caspar Baum

unread,
Nov 19, 2020, 10:26:40 AM11/19/20
to qz-print
Hello,

our warehouse webservice software uses qz to print out the labels on an TSC TDP 247 Label printer and the Delivery Dokument on a "normal" printer.

The Label printing job works fine, but the normal print job for the delivery dokuments (PDF - 150kb size) always throws this error. ALso both documents on the label printer works fine.

java.lang.RuntimeException: Cannot call method public void qz.ws.PrintSocketClient#onMessage(org.eclipse.jetty.websocket.api.Session, java.io.Reader) with args: [org.eclipse.jetty.websocket.common.WebSocketSession, org.eclipse.jetty.websocket.common.message.MessageReader]
at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.unwrapRuntimeException(CallableMethod.java:93)
at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.call(CallableMethod.java:75)
at org.eclipse.jetty.websocket.common.events.annotated.OptionalSessionCallableMethod.call(OptionalSessionCallableMethod.java:68)
at org.eclipse.jetty.websocket.common.events.JettyAnnotatedEventDriver$2.run(JettyAnnotatedEventDriver.java:227)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:914)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Java heap space


My setup:
win10 pro
64 Bit OS
4GM RAM
Intel Celeron N4100 1.10 GHz 1.10 GHz
Java 8 Update 271 (64 bit) Version 8.0.2710.9 - no 32 bit version installed at all

I tried both versions of QZ 2.0.2 and 2.1.12.... I have no clue, whats the point to throw this error on two different pc´s. The software works fine on so many other pc/laptops and also on IOS =/. 

Do you have any tips/ideas for me?

Best regards,
Caspar

Tres Finocchiaro

unread,
Nov 19, 2020, 11:26:00 AM11/19/20
to Caspar Baum, qz-print
Have you tried { rasterize: false }  in your config?

4GB is generally too little memory for QZ, because with 64-bit Java, the JVM allocates the heap based on a percentage of available memory.

You could try to force a larger heap using an environmental variable.


--
You received this message because you are subscribed to the Google Groups "qz-print" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qz-print/13f96ad4-012a-4a2e-ace4-e8c235baff68n%40googlegroups.com.

Caspar Baum

unread,
Nov 19, 2020, 12:02:51 PM11/19/20
to qz-print
Thanks for your fast reply!

I didn´t found a way to config qz, beacuse I didnt wrote the script to communictae with QZ, we only use a alredy existing software solution.
Or is there a way as "User" to config my local QZ Installation with this attribute?

This error also occure with two different laptops with 8GM RAM....

I am at my wit's end.


Lite Finocchiaro

unread,
Nov 19, 2020, 12:43:45 PM11/19/20
to Caspar Baum, qz-print
Caspar:

 The config will be apparent in the logs. If you see "rasterize: 'true'" then you'll have to escalate with your web developer. 

I can help with that if it's a premium subscriber. Feel free to reach out to me privately at li...@qz.io

Regards,

Lite Finocchiaro
VP, QZ Industries



Tres Finocchiaro

unread,
Nov 19, 2020, 12:50:37 PM11/19/20
to Caspar Baum, qz-print
Caspar,

Understood. Try this (picture attached)

Note the value -Xmx1024m can be adjusted, but QZ Tray won't launch if it's too big of a value.

What this does is it allocate more memory.  You'll have to test it out by printing a few times and see if it's enough.

I tried setting it to 2048 on a machine with 4GB and it wouldn't start, so adjust as needed.

In the meantime, if you do have the ability to order more memory for your computer, that will greatly help this issue.

-Tres

image.png






Tres Finocchiaro

unread,
Nov 19, 2020, 12:51:34 PM11/19/20
to Caspar Baum, qz-print
Oh, QZ Tray will need to be restarted for the changes to take effect.

Caspar Baum

unread,
Nov 19, 2020, 1:34:06 PM11/19/20
to Tres Finocchiaro, qz-print
@Lite the  "rasterize attribute is "false", so this could not solve the problem.

@Tres : i adjusted the env variables as you described, many thanks for this. But unfortunaly the problem still exist.. Her the Error Log from the last run. ( I restarted my pc after the adjustments)


java.lang.RuntimeException: Cannot call method public void qz.ws.PrintSocketClient#onMessage(org.eclipse.jetty.websocket.api.Session, java.io.Reader) with args: [org.eclipse.jetty.websocket.common.WebSocketSession, org.eclipse.jetty.websocket.common.message.MessageReader]
at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.unwrapRuntimeException(CallableMethod.java:93)
at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.call(CallableMethod.java:75)
at org.eclipse.jetty.websocket.common.events.annotated.OptionalSessionCallableMethod.call(OptionalSessionCallableMethod.java:68)
at org.eclipse.jetty.websocket.common.events.JettyAnnotatedEventDriver$2.run(JettyAnnotatedEventDriver.java:227)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:914)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.<init>(Unknown Source)
at java.awt.image.Raster.createPackedRaster(Unknown Source)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
at java.awt.image.BufferedImage.<init>(Unknown Source)
at org.apache.pdfbox.rendering.PageDrawer$TransparencyGroup.<init>(PageDrawer.java:1630)
at org.apache.pdfbox.rendering.PageDrawer$TransparencyGroup.<init>(PageDrawer.java:1551)
at org.apache.pdfbox.rendering.PageDrawer.showTransparencyGroup(PageDrawer.java:1486)
at org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:66)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:869)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:505)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processTransparencyGroup(PDFStreamEngine.java:240)
at org.apache.pdfbox.rendering.PageDrawer.access$1800(PageDrawer.java:117)
at org.apache.pdfbox.rendering.PageDrawer$TransparencyGroup.<init>(PageDrawer.java:1712)
at org.apache.pdfbox.rendering.PageDrawer$TransparencyGroup.<init>(PageDrawer.java:1551)
at org.apache.pdfbox.rendering.PageDrawer.showTransparencyGroup(PageDrawer.java:1486)
at org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:66)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:869)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:505)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processTransparencyGroup(PDFStreamEngine.java:240)
at org.apache.pdfbox.rendering.PageDrawer.access$1800(PageDrawer.java:117)
at org.apache.pdfbox.rendering.PageDrawer$TransparencyGroup.<init>(PageDrawer.java:1712)
at org.apache.pdfbox.rendering.PageDrawer$TransparencyGroup.<init>(PageDrawer.java:1551)
at org.apache.pdfbox.rendering.PageDrawer.showTransparencyGroup(PageDrawer.java:1486)
at org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:66)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:869)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:505)
at org.apache.pdfbox.contentstream.PDFStreamEngine.processTransparencyGroup(PDFStreamEngine.java:240)
at org.apache.pdfbox.rendering.PageDrawer.access$1800(PageDrawer.java:117)
at org.apache.pdfbox.rendering.PageDrawer$TransparencyGroup.<init>(PageDrawer.java:1712)
at org.apache.pdfbox.rendering.PageDrawer$TransparencyGroup.<init>(PageDrawer.java:1551)
at org.apache.pdfbox.rendering.PageDrawer.showTransparencyGroup(PageDrawer.java:1486)
at org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:66)

Any other solutions.... 

Many thanks for your help!

Caspar Baum
Feelgrounds™ - Let’s make barefoot shoes cool!
Feelgrounds Ltd, Georgiou Matsaki 4, Office #301, 6050 Larnaca, Cyprus, Reg. No. HE 374785 (Nicosia)

Tres Finocchiaro

unread,
Nov 19, 2020, 5:14:58 PM11/19/20
to Caspar Baum, qz-print
Nov 19, 2020 10:53:46 PM org.apache.pdfbox.contentstream.operator.graphics.DrawObject process
SCHWERWIEGEND: recursion is too deep, skipping form XObject
Nov 19, 2020 10:53:46 PM org.apache.pdfbox.contentstream.operator.graphics.DrawObject process
SCHWERWIEGEND: recursion is too deep, skipping form XObject
Nov 19, 2020 10:53:47 PM org.apache.pdfbox.contentstream.operator.graphics.DrawObject process
SCHWERWIEGEND: recursion is too deep, skipping form XObject

We're able to reproduce.  This reminds me a bit of https://issues.apache.org/jira/browse/PDFBOX-4380, since lowering the DPI doesn't crash the JVM.

Although, I think the machine is suffering from a new issue with recursive XObjects in the PDF.  Filed a bug report upstream to see if PDFBOX can be enhanced to not crash in this scenario:

Meanwhile, I'll reach out to the Premium Support subscriber and ask their developers to review the TCPDF code for this particular file.  The TCPDF version they used to create it was 6.2.26.

-Tres

crash_pdf.pdf

Tres Finocchiaro

unread,
Nov 21, 2020, 11:45:10 AM11/21/20
to Caspar Baum, qz-print
Just an update, it turns out that the PDF shows an error in Adobe as well when opened.  This should be enough to convince the software provider that there's a bug with the PDF generation.

The out-of-memory is a two-fold problem.
  1. Too many levels of references inside the document
  2. Force rasterization due to transparency
I've pinged PDFBOX about how to ignore transparency, but it's not straight-forward, so for maximum performance, both issues will need to be fixed by the website creating the PDF. https://github.com/AdoptOpenJDK/openjdk-support/issues/23#issuecomment-731602247

We may be able to fix the transparency-forces-rasterization "bug" downstream, but it will take some time, so the website will need to fix the PDF for immediate resolution.  Sorry for the inconvenience this has caused.

Tres Finocchiaro

unread,
Nov 21, 2020, 11:45:54 AM11/21/20
to Caspar Baum, qz-print
Reply all
Reply to author
Forward
0 new messages