Jasper
memory issue while generating XLs report
Why is the problem –
-
Jasper - due to its template based nature of
excel generation it is very costly affair to use specially regarding heap
usage. Tested in JProbe, it points all jasper classes consuming large amount of
heap memory.
-
POI - It has limit of 65,000 rows with HSSF. Tested
both HSSF and XSSF on the local workstation. Could create 10,000 rows with HSSF
and received outofmemory exception, and for XSSF, could never generate excel of 10,000 rows.
Looks expensive. Jboss heap setting was JAVA_OPTS="-Xms128m -Xmx512m -XX
-
JXL - very light, and of course is not as rich
as POI but can create 65000 rows very easily with above mentioned heap setting
on local JBoss server.
Why you cannot fix
without server –
-
You can increasing JVML heap will help till a
certain limit, for 32-bit machine JVM max you can allocate 2 GB after that you
need to shift 64-bit
What you can do in
Jasper
-
For filling and exporting large documents that
would normally eat up memory and crash with an OutOfMemory exception, there is
now a new feature called "report virtualizer" that uses serialization
of temporary data on disk to optimize memory consumption. This can be seen in
action in the supplied /demo/samples/virtualizer sample provided. This new
feature is a contribution from Works Inc.
What you can do with XLs
-
Excel 2007 is now capable of processing over a
million rows of data in .xlsx files but .xls retains its 65k limit. XSSF (part
of poi 3.5) will let you write .xslx files without the row limits
What you can do at coding level
1. creates a
template workbook
2. generates a
sample XML with random data. It can be a really large XML with millions of rows
and thousands of columns.
3. substitutes the
sheet in the template with the generated xml