Note that there are some explanatory texts on larger screens.

plurals
  1. POJasper Reports OutOfMemoryError on export
    primarykey
    data
    text
    <p>I have written a web app for managing and running Jasper reports. Lately I've been working with some reports that generate extremely large (1500+ page) outputs, and attempting to resolve the resultant memory issues. I have discovered the <a href="http://jasperreports.sourceforge.net/sample.reference/virtualizer/index.html" rel="nofollow"><code>JRFileVirtualizer</code></a>, which has allowed me to run the report successfully with a very limited memory footprint. However, one of the features of my application is that it stores output files from previously run reports, and allows them to be exported to various formats (PDF, CSV, etc.). Therefore, I find myself in the situation of having a 500+MB .jrprint file and wanting to export it to, for example, CSV on demand. Here is some simplified example code:</p> <pre><code>JRCsvExporter exporter = new JRCsvExporter(); exporter.setParameter(JRExporterParameter.INPUT_FILE_NAME, jrprintPath); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream); exporter.exportReport(); </code></pre> <p>Unfortunately, when I attempt this on the large file I mentioned, I get an <code>OutOfMemoryError</code>:</p> <pre><code>Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded at java.io.ObjectInputStream$HandleTable.grow(ObjectInputStream.java:3421) at java.io.ObjectInputStream$HandleTable.assign(ObjectInputStream.java:3227) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1744) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at java.util.ArrayList.readObject(ArrayList.java:593) at sun.reflect.GeneratedMethodAccessor184.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at net.sf.jasperreports.engine.base.JRVirtualPrintPage.readObject(JRVirtualPrintPage.java:423) ... </code></pre> <p>From browsing some of the Jasper internals, it looks like no matter how I attempt to set up this export (I have also tried loading and setting the <code>JASPER_PRINT</code> parameter directly), there will ultimately be a call to <code>JRLoader.loadObject(...)</code> which will attempt to load my entire 500MB report into memory (see <code>net.sf.jasperreports.engine.JRAbstractExporter.setInput()</code>).</p> <p>My question is, is there a way around this that doesn't involve just throwing memory at the problem? 500MB is doable, but it doesn't leave my application very future-proof, and the <code>JRVirtualizer</code> solution for report execution leaves me hoping there will be something similar for export. I am willing to get my hands dirty and extend some of the Jasper internal classes, but the ideal solution would be one provided by Jasper itself, for obvious reasons.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload