Exporting a report to PDF can cause an out of memory issue when the PDF has a large number of rows. This is often in combination with large text columns. When this problem occurs, the base system constraints that are handled by the following system properties have not been changed:

  • glide.pdf.max_rows
  • glide.pdf.max_columns

For more information about these system properties, see Export limit properties in the ServiceNow product documentation.

Steps to Reproduce

  1. Create a report with:
    • 5,000 rows returned
    • some columns are large text fields
  2. Export the report to PDF.
    Note that as the report is exported, the node runs out of memory with an error in the logs similar to the following:

2017-03-02 06:12:19 (907) worker.1 worker.1 Time: 0:00:03.157 id: <instance_name>_1[glide.17] for: /* <instance_name>006, gs:glide.scheduler.worker.1, tx:816f18414f1532005c55ca1f0310c768 */ SELECT task0.`sys_id` FROM (task task0 ignore index(task_index3) LEFT JOIN cmdb cmdb1 ON task0.`u_business_service` = cmdb1.`sys_id` ) WHERE task0.`sys_class_name` = 'incident' AND cmdb1.`name` LIKE '%booster%' ORDER BY task0.`number` DESC limit 0,5000 

2017-03-02 06:12:46 (080) worker.1 worker.1 [0:00:00.414] Compacting large row block 
2017-03-02 06:12:46 (092) worker.1 worker.1 [0:00:00.011] Compacting large row block 
2017-03-02 06:12:46 (193) worker.1 worker.1 [0:00:00.101] Expanding large row block 
2017-03-02 06:12:46 (557) worker.1 worker.1 [0:00:00.363] Compacting large row block 
2017-03-02 06:12:46 (561) worker.1 worker.1 [0:00:00.004] Expanding large row block 
2017-03-02 06:12:46 (590) worker.1 worker.1 [0:00:00.015] Compacting large row block 
2017-03-02 06:12:46 (704) worker.1 worker.1 [0:00:00.114] Expanding large row block 
2017-03-02 06:12:47 (296) worker.1 worker.1 [0:00:00.462] Compacting large row block 
2017-03-02 06:12:47 (299) worker.1 worker.1 [0:00:00.003] Expanding large row block 
2017-03-02 06:14:03 (057) worker.1 worker.1 SEVERE *** ERROR *** Failure during scheduled run of job: 81c92ce9c0a8016400e5f0d2f784ea78
java.lang.OutOfMemoryError: Java heap space 
at java.util.Arrays.copyOf(Arrays.java:3236) 
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118) 
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) 
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153) 
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122) 
at java.io.FilterOutputStream.write(FilterOutputStream.java:97) 
at com.itextpdf.text.pdf.OutputStreamCounter.write(OutputStreamCounter.java:105) 
at com.itextpdf.text.pdf.PdfStream.toPdf(PdfStream.java:358) 
at com.itextpdf.text.pdf.PdfIndirectObject.writeTo(PdfIndirectObject.java:158) 
at com.itextpdf.text.pdf.PdfWriter$PdfBody.write(PdfWriter.java:420) 
at com.itextpdf.text.pdf.PdfWriter$PdfBody.add(PdfWriter.java:398) 
at com.itextpdf.text.pdf.PdfWriter$PdfBody.add(PdfWriter.java:377) 
at com.itextpdf.text.pdf.PdfWriter$PdfBody.add(PdfWriter.java:330) 
at com.itextpdf.text.pdf.PdfWriter.addToBody(PdfWriter.java:815) 
at com.itextpdf.text.pdf.PdfWriter.add(PdfWriter.java:3278) 
at com.itextpdf.text.pdf.PdfWriter.addDirectImageSimple(PdfWriter.java:3252) 
at com.itextpdf.text.pdf.PdfWriter.addDirectImageSimple(PdfWriter.java:3179) 
at com.itextpdf.text.pdf.PdfContentByte.addImage(PdfContentByte.java:1473) 
at com.itextpdf.text.pdf.PdfContentByte.addImage(PdfContentByte.java:1335) 
at com.itextpdf.text.pdf.PdfDocument.writeLineToContent(PdfDocument.java:1677) 
at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:1024) 
at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:878) 
at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:867) 
at com.itextpdf.text.pdf.PdfPRow.writeCells(PdfPRow.java:550) 
at com.itextpdf.text.pdf.PdfPTable.writeSelectedRows(PdfPTable.java:777) 
at com.itextpdf.text.pdf.PdfPTable.writeSelectedRows(PdfPTable.java:907) 
at com.itextpdf.text.pdf.PdfPTable.writeSelectedRows(PdfPTable.java:855) 
at com.itextpdf.text.pdf.PdfPTable.writeSelectedRows(PdfPTable.java:833) 
at com.glide.generators.PDFHdrFtrGenerator.onEndPage(PDFHdrFtrGenerator.java:165) 
at com.itextpdf.text.pdf.PdfDocument.newPage(PdfDocument.java:930) 
at com.itextpdf.text.pdf.PdfDocument.addPTable(PdfDocument.java:2649) 
at com.itextpdf.text.pdf.PdfDocument.add(PdfDocument.java:746) 

Note: The query returning the large set right before the "Java heap space" error (highlighted above) is the query you want to target for the workaround. Sometimes adding particular conditions or removing large text columns from the export can provide relief.



There are two possible workarounds:

  • Limit the number of rows that you can export by setting the glide.pdf.max_rows system property to 1,000

  • Find the report that generated the export.
    • Add conditions. The result set returned from the affected report is very large - are there any additional conditions that can be added to limit the amount of records returned (and subsequently processed in memory when exporting the report)?
    • Remove large text columns. Are there large text columns, such as journal fields, that you are trying to export? Can these be removed?

Related Problem: PRB923321

Seen In

There is no data to report.

Fixed In

Istanbul Patch 10
Jakarta Patch 4

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-04-13 09:47:21