views:

734

answers:

1

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.

A: 

Hi Stanley,

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...

Deger