简体   繁体   中英

how to use JRSwapFileVirtualizer for jasper reports in java

how to use JRSwapFileVirtualizer for jasper reports in java, this is the code which i use..

JRSwapFileVirtualizer virtualizer = null;
virtualizer = new JRSwapFileVirtualizer(10000, new JRSwapFile("F://", 1000, 1000), false);
param.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);

xmlDataSource = new JRXmlDataSource(reportFile,"/table/tr");
jasperPrint = JasperFillManager.fillReport(jasperpath, param, xmlDataSource);

still i get the heap space error(OutOfMemeoryException), and the file which gets created is empty.

First parameter of the constructor of the JRSwapFileVirtualizer is the maximum number of report pages that will be stored in primary memory (RAM) before sections of the report are stored in virtual memory (disk). So if your report page size does not exceed 10000 page then you are not able to store them in virtual memory and even though you write the virtualizer code you are not actually using this beauty.

Try something like,

JRSwapFileVirtualizer virtualizer = null; 
virtualizer = new JRSwapFileVirtualizer(3, new JRSwapFile("F://", 2048, 1024), false); 
param.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);

Hope it works :-)

cheers...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM