The JRFileVirtualizer is original, but it was mostly proof of concept (written when I evaluated JR, JR developers also fixed it). It creates a separate file for each virtualized page, which can lead to a large number of temporary files.
I recommend using JRSwapFileVirtualizer because it creates only one file for the report.
JRSwapFileVirtualizer virtualizer = null;
try {
JRSwapFile swapFile = new JRSwapFile("directory", 1024, 100);
virtualizer = new JRSwapFileVirtualizer(50, swapFile, true);
params.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
...
JasperPrinter printer = JasperFillManager.fillReport(report, params, dataSource);
...
}
finally {
if (virtualizer != null) virtualizer.cleanup();
}
This will force the system to delete the page file when it is done with the report, and will use the virtualizer to store reports with more than 50 pages.
JRGzipVirtualizer was another poc virtualizer designed for diskless systems. Report page objects are compressed very well, so you can create large reports if you have a decent heap memory size.
source
share