Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasper Print - Java Heap space memory

Am using Jasper Reports to generate the reports. But I have huge data coming from the Database. While executing Jasper print to fill the Report data, it is taking huge memory and giving the Java Heap Space memory issues.

JasperPrint jasperPrint = JasperFillManager.fillReport(
                    jasperReport, params, dataSource);

This is the line taking so much time and giving error. Please help me, how to come out of this issue.

Stackrace : 
java.lang.OutOfMemoryError: Java heap space
    at net.sf.jasperreports.engine.fill.JRFillTextField.fill(JRFillTextField.java:691)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.fillElements(JRFillElementContainer.java:570)
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:390)
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:351)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2039)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:771)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:301)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:148)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:841)
    at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:88)
    at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:653)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:969)
    at com.jci.eprt.web.controller.report.ReportController.previewEngineeringReport(ReportController.java:250)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.jci.eprt.service.utility.helper.JCIUserFilter.doFilter(JCIUserFilter.java:39)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
like image 309
Manjunath Avatar asked Apr 22 '26 04:04

Manjunath


1 Answers

This is a common issue when you are dealing with reports with huge result set. An obvious solution is not to read the whole result-set at once and try reading it incrementally instead.

A detailed explanation about dealing with this issue is provided in Java DevZone: Generating Huge reports in JasperReports. A few lines written in this reference:

There are certain things to care while implementing the Jasper Reports for huge dataset to handle the memory efficiently, so that the appliacation does not go out of memory.

They are:

1) Pagination of the data and use of JRDataSource,

2) Viruatization of the report.

like image 152
Mohammad Dashti Avatar answered Apr 23 '26 17:04

Mohammad Dashti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!