Closed klabarge closed 8 years ago
Some observations... (Java 8 update 45)
1,400 MB
, it would settle back down to 660 MB
once the limit was reached, so the garbage collector was kicking in properly.However, when chaining HTML printing to the tail end, the jobs would eventually fail. I believe whatever memory caps @bberenz observed when doing HTML printing are starting to crop up again. PDFBOX seems to be able to handle it much more gracefully. This makes more sense to me as some of our premium customers have not yet complained of this. Let me know if your testing results differ.
This looks like an issue with multiple concurrent print jobs running. Seems to be a limit around 512mb per job for all the resources required. (Sending 10 print jobs at once is a great way to reproduce).
Forcing synchronized
on the print request calls would fix this problem as it creates a choke point on the resources. But this also limits how quickly systems with enough memory can process.
I've created a pool system for the print processors, keeping a limit on how many processors can run simultaneously. Allowing larger systems to power through and smaller systems to avoid crashing.
The fix is under e8f353b699ed60d88edb243a5446d6c5a95b7f82, but I'll leave this open until you can verify it's handled properly on all systems.
I am unable to print on my Windows 10 machine with this.
This seems to be working okay on Mac
The stack trace below is from an HTML print, but the results are the same for PDF, Image, and I also tested some raw printing.
Notice the last line says "Allowing 0 simultaneous processors based on memory available"
[DEBUG] 2016-04-08 19:47:21,395 @ qz.ws.PrintSocketClient:?
Message: {"call":"print","promise":{},"params":{"printer":{"name":"Micro
soft XPS Document Writer"},"options":{"colorType":"color","copies":"1","density"
:"","duplex":false,"interpolation":"","jobName":"","margins":"0","orientation":"
","paperThickness":"","printerTray":"","rasterize":true,"rotation":"","scaleCont
ent":true,"size":{"width":"","height":""},"units":"in","altPrinting":false,"enco
ding":"","endOfDoc":"","perSpool":"1"},"data":[{"type":"html","format":"plain","
data":"<html> <table style=\"font-family: monospace; border: 1px;\"> <tr
style=\"height: 6cm;\"> <td valign=\"top\"><h2>* QZ Print Plugi
n HTML Printing *</h2><span style=\"color: #F00;\">Version:</span> 2.0.0-R
C5<br/><span style=\"color: #F00;\">Visit:</span> https://qz.io/</td>
<td valign=\"top\"><img src=\"https://demo.qz.io/assets/img/image_sample.png\"><
/td> </tr> </table></html>"}]},"timestamp":1460159241376,"uid":"2x0env"}
[WARN] 2016-04-08 19:47:21,400 @ qz.ws.PrintSocketClient:?
Bad signature on request
[INFO] 2016-04-08 19:47:33,136 @ qz.common.TrayManager:?
Allowed localhost to print to Microsoft XPS Document Writer
[DEBUG] 2016-04-08 19:47:33,140 @ qz.printer.PrintServiceMatcher:?
Searching for PrintService matching Microsoft XPS Document Writer
[DEBUG] 2016-04-08 19:47:33,174 @ qz.printer.PrintServiceMatcher:?
Found 10 printers
[DEBUG] 2016-04-08 19:47:33,175 @ qz.printer.PrintServiceMatcher:?
Found match: Microsoft XPS Document Writer
[WARN] 2016-04-08 19:47:33,186 @ qz.printer.PrintOptions:?
Cannot read as a double for density, using default
[WARN] 2016-04-08 19:47:33,187 @ qz.printer.PrintOptions:?
Cannot read as a valid value for interpolation, using default
[WARN] 2016-04-08 19:47:33,190 @ qz.printer.PrintOptions:?
Cannot read as a valid value for orientation, using default
[WARN] 2016-04-08 19:47:33,191 @ qz.printer.PrintOptions:?
Cannot read as a double for paperThickness, using default
[WARN] 2016-04-08 19:47:33,192 @ qz.printer.PrintOptions:?
Cannot read as a double for rotation, using default
[WARN] 2016-04-08 19:47:33,194 @ qz.printer.PrintOptions:?
Cannot read as a double for size.width, using default
[WARN] 2016-04-08 19:47:33,195 @ qz.printer.PrintOptions:?
Cannot read as a double for size.height, using default
[DEBUG] 2016-04-08 19:47:33,426 @ qz.utils.PrintingUtilities:?
Found Resolution: 60000x60000 dphi
[DEBUG] 2016-04-08 19:47:33,781 @ qz.utils.PrintingUtilities:?
Allowing 0 simultaneous processors based on memory available
Should avoid that scenario now (79fa6f433197a45fc284d4ef79bb1364d58ae22a)
Out of curiosity, are you still running with -Xmx1024m
? As that should have given you 2 print processors.
For testing I launched it normally. I will test with both and report back. On Apr 8, 2016 9:13 PM, "bberenz" notifications@github.com wrote:
Should avoid that scenario now (79fa6f4 https://github.com/qzind/tray/commit/79fa6f433197a45fc284d4ef79bb1364d58ae22a ) Out of curiosity, are you still running with -Xmx1024m? As that should have given you 2 print processors.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/qzind/tray/issues/27#issuecomment-207675879
So Mac has an interesting way of reporting and handling the memory...
In my case, the physical machine had 16 GB
available to it...
pdf_sample.pdf
65 times causes QZ Tray to request over 2 GB
of ram28 MB
!2 GB
(compressed sticking around 30 MB
regardless)Summary
Windows XP test results (Firefox 43, 2 GB
ram, Java 1.8 u77)
Print PDF
java.lang.OutOfMemoryError
on first press of Print PDF button200 MB
cmd
with -Xms512m -Xmx1024m
seems to circumvent the issuePrint HTML
[TRACE] 2016-04-09 14:06:54,895 @ qz.printer.action.WebApp:?
Waiting for JavaFX..
Graphics Device initialization failed for : d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.init(Unknown Source)
at com.sun.javafx.tk.Toolkit.getToolkit(Unknown Source)
at com.sun.javafx.application.PlatformImpl.startup(Unknown Source)
at com.sun.javafx.application.LauncherImpl.startToolkit(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(Unknown Source)
... 1 more
Exception in thread "Thread-47" java.lang.RuntimeException: No toolkit found
at com.sun.javafx.tk.Toolkit.getToolkit(Unknown Source)
at com.sun.javafx.application.PlatformImpl.startup(Unknown Source)
at com.sun.javafx.application.LauncherImpl.startToolkit(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[TRACE] 2016-04-09 14:06:55,897 @ qz.printer.action.WebApp:?
Waiting for JavaFX..
[TRACE] 2016-04-09 14:06:56,898 @ qz.printer.action.WebApp:?
Waiting for JavaFX..
[TRACE] 2016-04-09 14:06:57,899 @ qz.printer.action.WebApp:?
Waiting for JavaFX..
[TRACE] 2016-04-09 14:06:58,901 @ qz.printer.action.WebApp:?
Waiting for JavaFX..
[ERROR] 2016-04-09 14:06:59,902 @ qz.ws.PrintSocketClient:?
Failed to print
java.lang.UnsupportedOperationException: Unable to start JavaFX service
at qz.printer.action.PrintHTML.parseData(Unknown Source)
at qz.ws.PrintSocketClient.processPrintRequest(Unknown Source)
at qz.ws.PrintSocketClient.processMessage(Unknown Source)
at qz.ws.PrintSocketClient.onMessage(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.call(CallableMethod.java:70)
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:210)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: JavaFX did not start
at qz.printer.action.WebApp.initialize(Unknown Source)
... 14 more
Using Ubuntu Linux 14.04 LTS x64 8-core AMD 8320 processor, (24GB RAM on machine) no launch parameters
Inital startup/install: 216MB Find Printer: 220MB First PDF Print job: 624MB, then settles down to 620MB Second PDF Print job: 647MB, settles down to 640MB Third PDF Print job: 642MB Clicking PDF the 4th-12th time in rapid succession: 866MB After waiting 5 minutes and just idling: 571MB Sending another print job shortly after waiting 5 minutes: 918MB Additional print job after another 5 minutes: 918MB After idling for 10 more minutes: 917MB Update: 918MB after ten more minutes.
Using Ubuntu Linux 14.04 LTS x64 8-core AMD 8320 processor, (24GB RAM on machine) no launch parameters
Initial startup: 216MB First HTML print job: 1.4GB Second HTML print job: 2.4GB Third HTML print job: 3.4GB Fourth HTML print job: 4.4GB 5th-25th print jobs: holding steady at 4.6GB Still 4.6GB after forty-five minutes with no activity.
Linux Mint x64 17.3 with 6GB RAM,4-core intel i5, no launch parameters
Initial startup: 178MB First HTML print job: 280MB Second HTML print job: 280MB Third-15th HTML print job: 280MB Fifteen minutes later, only at 282MB
Out of curiosity, are you still running with -Xmx1024m? As that should have given you 2 print processors.
When launching with -Xmx1024m
, the console shows: Allowing 2 simultaneous processors based on memory available
:+1:
I get similar results on my Windows 10 (16GB RAM) laptop as Tres did on XP.
java.lang.OutOfMemoryError
512MB
, I was able to print 4 times. On the 5th print, I did not receive the java.lang.OutOfMemoryError
, but the software seemed to freeze at this point.
Found Resolution: 60000x60000 dphi
[DEBUG] 2016-04-10 19:14:19,644 @ qz.ws.PrintSocketClient:?
Message: {"call":"print","promise":{},"params":{"printer":{"name":"Microsoft XPS Document Writer"},"options":{"colorType":"color","copies":"1","density":"","duplex":false,"interpolation":"","jobName":"","margins":"0","orientation":"","paperThickness":"","printerTray":"","rasterize":true,"rotation":"0","scaleContent":true,"size":null,"units":"in","altPrinting":false,"encoding":"","endOfDoc":"","perSpool":"1"},"data":[{"type":"pdf","data":"https://demo.qz.io/assets/pdf_sample.pdf"}]},"timestamp":1460330059639,"uid":"eho83k"}
[WARN] 2016-04-10 19:14:19,648 @ qz.ws.PrintSocketClient:?
Bad signature on request
[INFO] 2016-04-10 19:14:21,299 @ qz.common.TrayManager:?
Allowed localhost to print to Microsoft XPS Document Writer
[DEBUG] 2016-04-10 19:14:21,300 @ qz.printer.PrintServiceMatcher:?
Searching for PrintService matching Microsoft XPS Document Writer
[DEBUG] 2016-04-10 19:14:21,301 @ qz.printer.PrintServiceMatcher:?
Found 9 printers
[DEBUG] 2016-04-10 19:14:21,303 @ qz.printer.PrintServiceMatcher:?
Found match: Microsoft XPS Document Writer
[WARN] 2016-04-10 19:14:21,305 @ qz.printer.PrintOptions:?
Cannot read as a double for density, using default
[WARN] 2016-04-10 19:14:21,306 @ qz.printer.PrintOptions:?
Cannot read as a valid value for interpolation, using default
[WARN] 2016-04-10 19:14:21,308 @ qz.printer.PrintOptions:?
Cannot read as a valid value for orientation, using default
[WARN] 2016-04-10 19:14:21,310 @ qz.printer.PrintOptions:?
Cannot read as a double for paperThickness, using default
[DEBUG] 2016-04-10 19:14:21,312 @ qz.utils.PrintingUtilities:?
Found Resolution: 60000x60000 dphi
java.lang.OutOfMemoryError
:[DEBUG] 2016-04-10 18:55:40,250 @ qz.ws.PrintSocketClient:?
Message: {"call":"print","promise":{},"params":{"printer":{"name":"Microsoft XPS Document Writer"},"options":{"colorType":"color","copies":"10","density":"","duplex":false,"interpolation":"","jobName":"","margins":"0","orientation":"","paperThickness":"","printerTray":"","rasterize":true,"rotation":"0","scaleContent":true,"size":null,"units":"in","altPrinting":false,"encoding":"","endOfDoc":"","perSpool":"1"},"data":[{"type":"pdf","data":"https://demo.qz.io/assets/pdf_sample.pdf"}]},"timestamp":1460328940245,"uid":"da71h4"}
[WARN] 2016-04-10 18:55:40,256 @ qz.ws.PrintSocketClient:?
Bad signature on request
[INFO] 2016-04-10 18:55:41,295 @ qz.common.TrayManager:?
Allowed localhost to print to Microsoft XPS Document Writer
[DEBUG] 2016-04-10 18:55:41,300 @ qz.printer.PrintServiceMatcher:?
Searching for PrintService matching Microsoft XPS Document Writer
[DEBUG] 2016-04-10 18:55:41,331 @ qz.printer.PrintServiceMatcher:?
Found 9 printers
[DEBUG] 2016-04-10 18:55:41,333 @ qz.printer.PrintServiceMatcher:?
Found match: Microsoft XPS Document Writer
[WARN] 2016-04-10 18:55:41,346 @ qz.printer.PrintOptions:?
Cannot read as a double for density, using default
[WARN] 2016-04-10 18:55:41,346 @ qz.printer.PrintOptions:?
Cannot read as a valid value for interpolation, using default
[WARN] 2016-04-10 18:55:41,349 @ qz.printer.PrintOptions:?
Cannot read as a valid value for orientation, using default
[WARN] 2016-04-10 18:55:41,350 @ qz.printer.PrintOptions:?
Cannot read as a double for paperThickness, using default
[DEBUG] 2016-04-10 18:55:41,584 @ qz.utils.PrintingUtilities:?
Found Resolution: 60000x60000 dphi
[DEBUG] 2016-04-10 18:55:41,837 @ qz.utils.PrintingUtilities:?
Allowing 1 simultaneous processors based on memory available
[DEBUG] 2016-04-10 18:55:41,856 @ qz.ws.PrintSocketClient:?
Using qz.printer.action.PrintPDF to print
[DEBUG] 2016-04-10 18:55:42,918 @ qz.printer.action.PrintPDF:?
Parsed 1 files for printing
[TRACE] 2016-04-10 18:55:43,028 @ qz.printer.action.PrintPixel:?
DPI: 600.0 CNV: 72.0
[TRACE] 2016-04-10 18:55:43,029 @ qz.printer.action.PrintPixel:?
Drawable area: 0.0,0.0:8.268001,11.693
[TRACE] 2016-04-10 18:55:43,030 @ qz.printer.action.PrintPixel:?
[color, 60000x60000 dphi, (0.0,0.0)->(210.007,297.002)mm]
[INFO] 2016-04-10 18:55:43,048 @ qz.printer.action.PrintPixel:?
Starting printing (10 copies)
[ERROR] 2016-04-10 18:55:54,760 @ qz.ws.PrintSocketClient:?
Connection error
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:210)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
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.printing.PDFPrintable.print(PDFPrintable.java:169)
at sun.awt.windows.WPathGraphics.redrawRegion(Unknown Source)
at sun.print.RasterPrinterJob.printPage(Unknown Source)
at sun.print.RasterPrinterJob.print(Unknown Source)
at qz.printer.action.PrintPixel.printCopies(Unknown Source)
at qz.printer.action.PrintPDF.print(Unknown Source)
at qz.ws.PrintSocketClient.processPrintRequest(Unknown Source)
at qz.ws.PrintSocketClient.processMessage(Unknown Source)
at qz.ws.PrintSocketClient.onMessage(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.call(CallableMethod.java:70)
... 5 more
@klabarge Can you re-run without the VM args and post the updated logs from (182cce1241d5da196410eb23c7c0cba64dca91ce). I want to know what java is reporting as the default use memory on your system.
Rather, can you run java -XX:+PrintFlagsFinal -version | findstr HeapSize
(for windows or | grep HeapSize
on linux) from command line and post the results?
I accidentally closed this... :disappointed: although testing so far has proven to be successful since 64f291dd00b95265e741ffe6afc6f443df338f75
I will leave closed unless we run into another issue.
I was just going to note that launching QZ Tray from the console requires an extra argument from now on:
java -jar -Xms512m "%PROGRAMFILES%\QZ Tray\qz-tray.jar"
Tested on Windows 10
This seems to primarily happen when printing PDF's, but I have witnessed this issue with HTML printing as well.
Steps to reproduce:
Launch QZ Tray with 1GB of RAM:
View QZ Tray in the task manager.
Print a PDF and observe the memory usage increase, and then never decrease
Repeat until the memory cap is reached, and printing is no longer possible
Stack trace when Java runs out of memory and cannot print: