Reputation: 28596
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
Reputation: 2241
Apart from using a better XML parser, also check Jasper Reports - Virtualizer.
Upvotes: 0
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