marioosh
marioosh

Reputation: 28596

Jasper Reports and huge XML as data source

I have a huge .xml as data source (about 100 MB). How to prepare a pdf with this xml efficiently and without java.lang.OutOfMemoryError: Java heap space ?

HashMap<String, Object> params = new HashMap<String,Object>();
// below i get: java.lang.OutOfMemoryError
Document document = JRXmlUtils.parse(JRLoader.getLocationInputStream(dataSource)); 
params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
jasperPrint = JasperFillManager.fillReport(jasperReport, params);

Upvotes: 3

Views: 1149

Answers (2)

bchetty
bchetty

Reputation: 2241

Apart from using a better XML parser, also check Jasper Reports - Virtualizer.

Upvotes: 0

Andreas Dolk
Andreas Dolk

Reputation: 114837

You could increase the heap - if possible. But creating a DOM for a 100MB xml file plus creating a pdf document in the same JVM really requires a lot of memory. Try processing the input file with an event based SAX parser. That should decrease the memory footprint significantly!

Upvotes: 1

Related Questions