views:

1643

answers:

2

so, problem is when we are showing to user created document in JasperReport Dialog. User can press print icon and sent it to printer.

It seems to take too much resources on client's computer on all three levels: creating report, showing report on screen and sending it to printer. One example PC is AMD Duron 800MHz with 256MB of RAM so we need to see if we can do some optimizations for better user experience.

It also takes significant resources on 'normal' computer with 2GHz processor and 1GB RAM so I need to see if there is an option to tune JasperReport to behave less gready on resources.

A: 

Well Jasper Reports is simply a jar so you need to be more specific: are you running JasperReports in a Web app (on Tomcat, Glassfish, JBoss, etc) or are you running it in iReport?

If you're running it in an appserver the most obvious thing I can think of is to make sure you're using the right report compiler, namely the JDT compiler. Definitely make sure you're not using teh beanshell compiler. It's slow as hell.

cletus
Then make sure it's being run and executed with the Eclipse JDT compiler (the JasperReports dist comes with this in JAR form but you need to configure it to use it). If you're using JRBshCompiler, that's probably the cause.
cletus
+1  A: 

Excessive use of subreports can increase resource demands for a report. Each subreport spawns its own thread during fill time. Also if you are using scriptlets or helpers classes ensure all resources they create are being properly cleaned up. Also ensure you are using the latest JR package.

One note. The JR api includes a set of virtualizers. When the report is filling, the entire filled report is created as an object (JasperPrint). Depending on the numbers of pages in the report, this object can get pretty large. The virtualizers can be configured to write to the file system when a set page-threshold has been reached.

Typically this reduces overall memory usage but increases fill time. A comprise might be the gzip virtualizer which rather than writing to the file system, compresses the generated objects using gzip.

Here is an FAQ on the subject: http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/faq.html?group_id=252#FAQ13

The example it refers to can be obtained by downloading the JR source.

http://sourceforge.net/project/showfiles.php?group_id=36382&package_id=28579

From a high level view, if you are running this report in an application you can instantiate the virtualizer (here is the interface listing the known implementing classes): http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JRVirtualizer.html

Then the reference is used at fill time:

  JRDataSource ds = new JREmptyDataSource(10);
  JRFileVirtualizer virtualizer = new JRFileVirtualizer(2, "tmp");
  JasperPrint jasperPrint = fillReport(fileName, ds, virtualizer);

If you are in iReport a virtualizer can be configured in Options -> Settings.

I hope this is helpful.

Luke