I have a report that takes a select that return me about 900k records (it´s about 100MB of data) and I need to create a PDF with it.
So, my implementation is simple: I get the data from my JDBC Query, put into a ArrayList
and pass it to my report. I had some problems with memory but I fixed it, my problem now is with CPU processing (it is always at 100%) that makes my process crash.
My code is really simple:
public OutputStream getOutputStream(OutputStream out) {
try {
JasperPrint print = JasperFillManager.fillReport(jasperName, params, fillList);
JRExporter exporter = format.getExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
exporter.exportReport();
} catch (Exception e) {
throw new RuntimeException("Error getting the stream", e);
}
return out;
}
I would like to know:
- How in this case could I use my CPU´s multiple cores?
- Is there another strategy to do that?