mmastrangelo Posted September 28, 2006 Share Posted September 28, 2006 For various reasons, it is possible for the JasperReports engine to enter into an infinite loop while filling a report. Within this infinite loop, memory is slowly consumed until an OutOfMemoryError occurs, thus rendering the JVM useless until is is restarted. This behavior has been documented many times on this forum, and the typical response is that a report design issue is to blame. In my opinion, this makes JasperReports a danger to run in a production environment. Our application allows users to create their own reports and run them on the system. If they make a "mistake" on the design, however, they can actually cause a memory-chewing infinite loop on the production system. Is this going to be addressed in a future release? Aside from this problem, JasperReports is a great product. This is definitely a huge concern for anyone wanting to integrate it into a mission critical application.Post edited by: mmastrangelo, at: 2006/09/28 15:35 Link to comment Share on other sites More sharing options...
teodord Posted September 28, 2006 Share Posted September 28, 2006 Hi, We'll try do our best and solve this. The problem comes from the fact that it is difficult to detect that we are stuck in an infinite look. Thank you,Teodor Link to comment Share on other sites More sharing options...
mmastrangelo Posted September 29, 2006 Author Share Posted September 29, 2006 Teodor, Thanks for replying. We have addressed this issue by introducing a tolerance level in JRVerticalFiller. The tolerance level specifies the number of loops to allow; if it is exceeded, an exception is thrown. A possible solution could be to add a new attribute to the report design XML that allows users to specify such a tolerance level. This way it could be tailored to the needs of the report. Thanks,Matt Link to comment Share on other sites More sharing options...
tchriste Posted October 10, 2006 Share Posted October 10, 2006 I have downloaded the latest build, but I am unable to find the the tolerance level setting. Can you tell me where this setting is and in which build. I am using 1.2.7. Thank you. Link to comment Share on other sites More sharing options...
david_p Posted October 10, 2006 Share Posted October 10, 2006 I'v been having the same problem lately. Is there any way I can change my report layout to prevent these infinite loops?To me they seem to occur at random.Post edited by: david_p, at: 2006/10/10 09:10 Link to comment Share on other sites More sharing options...
mmastrangelo Posted October 10, 2006 Author Share Posted October 10, 2006 Hello, The tolerance level is a solution I implemented on my own by changing the source code. It is not part of JasperReports. I suggested this as a possible solution to prevent the infinite looping. I would be willing to share this code if Teodor thinks it could be useful. MattPost edited by: mmastrangelo, at: 2006/10/10 15:07 Link to comment Share on other sites More sharing options...
tchriste Posted October 10, 2006 Share Posted October 10, 2006 Hello, Well I am in a situation where extremely large reports are possible and I want to put a limit to the size of a particular report, so this tolerance level seems like the perfect solution because I am gettin out of memory errors on some reports. I would really appreciate your enhancement, unless there is a standard way to do this within jasper already. Link to comment Share on other sites More sharing options...
teodord Posted October 11, 2006 Share Posted October 11, 2006 Hi, Generating very large reports is not a problem if you rely on a virtualizer.Check the supplied /demo/samples/virtualizer sample. As for the tolerance level solution, Matt, please feel free and post it as a patch here:http://jasperforge.org/sf/tracker/do/listArtifacts/projects.jasperreports/tracker.patch Thank you,Teodor Link to comment Share on other sites More sharing options...
jkraemer Posted October 18, 2006 Share Posted October 18, 2006 Hello, Has the tolerance patch been posted? I still get the "Infinite Loop" error when I use the virtualizer solution. Thanks,James Link to comment Share on other sites More sharing options...
RoseRoo Posted October 23, 2006 Share Posted October 23, 2006 Hello:Did Matt post his solution already?I have 2 report falling into infinite loop...Or where I can find tolerance level settingon iReport? The deadline are nearing!!!:pinch: Link to comment Share on other sites More sharing options...
teodord Posted October 30, 2006 Share Posted October 30, 2006 Hi, Matt did not post yet his patch.We have thought about such a solution lately, but did not do anything in the code yet. Note that even if we are going to do something about abruptly getting out of infinite loops, it will not solve the problem with your report templates not working. This is because they have a layout problem and you need to review and refactor them to avoid it. Otherwise, the reports will still break, even with such patch in place. So if the deadline is approaching, you'd be better off rearranging the structure of your report template, to prevent infinit loops. Avoid using large bands and paying attention to subreports. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
RoseRoo Posted November 2, 2006 Share Posted November 2, 2006 Hello teodord:I have solve the Infinite looping by re-layout a new report...~_~"My partner has find out if a band large then some value,the report will crashedWe are not sure the certainty value yet...By the way, where I will find the "tolerance level setting"?Will it take some effect? Thanks for your reply & suggestion:cheer: --We are coming from TAIWAN Link to comment Share on other sites More sharing options...
mmastrangelo Posted November 2, 2006 Author Share Posted November 2, 2006 I haven't had a chance to post the tolerance level code yet. I'm hoping to have some time in the coming days to devote to this. I'm encouraged that users see this as a viable way to address the infinite looping problem. Link to comment Share on other sites More sharing options...
couetbis Posted October 24, 2007 Share Posted October 24, 2007 Hi,I have the same kind of problem :java.lang.OutOfMemoryError: Java heap spacenet.sf.jasperreports.engine.JRRuntimeException: java.lang.OutOfMemoryError: Java heap space at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:625) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:343) In my report, I have 2 subreports. In debuggage, I see that the program fill report, subreport1, subreport2, subreport2, subreport1, subreport1, subreport1 ... It's normal ?The problem run in a database but not in other database. It's data problem ? I'm desperate ... an idea please ?? Link to comment Share on other sites More sharing options...
hszetu Posted November 14, 2007 Share Posted November 14, 2007 Hi, I have the exact same problem with the subreport that ends up in a infinite loop. What I noticed is that when rendering the report, the subreport datasource call keeps rewinding, ending up in an infinite loop (next(), ..., next(), moveFirst(), next()...). The subreport is in the detail section of the main report. This seems to happen only when the subreport is big enough to cause the report to overflow to more than 1 page. If the report can fit in 1 page, the report can be generated without any problem. If this is a report layout issue, how do I fix the report layout? What do I have to look out for when designing the report to avoid the infinite loop problem? Thanks in advance.Henry Link to comment Share on other sites More sharing options...
hszetu Posted January 17, 2008 Share Posted January 17, 2008 Hi, Are there any work done in regards to prevent the infinite loop from happening? I have just tested the same report with version 2.0.4 and it still have the infinite loop problem. I debugged it and it boils down to the this snippet JRVerticalFiller.fillColumnBand() that ends up in an infinite loop when filling the detail section. Code:while (band.willOverflow()){ fillColumnBreak(evaluation, evaluation); printBand = band.fill(columnFooterOffsetY - offsetY - band.getHeight()); fillBand(printBand); offsetY += printBand.getHeight();} columnFooterOffsetY = 726offsetY = 234band.getHeight() = 290 It just having the exact same values when it is looping. I figured that it must have something to do with the detail section that might cause jasper into the infinite loop. In the detail section, there is a subreport and some static labels and text fields in it. So, I tried moving those labels and fields out of the detail section to the summary section and leaving the detail section contains only the subreport. This time the report is generated successfully, no infinite loop! Is that the cause of the infinite loop problem? Is it allow to have a detail band to have a subreport and at the same time with some labels and fields below the subreport? One thing I noticed is that the summary section does not fit in the rest of the first page(expected) and it is moved to the second page but the second page have no pageHeader nor pageFooter(unexpected)? I tried adding a lastPageFooter but it did not show on the summary page either? Isn't the pageHeader and pageFooter supposed to show on all pages? Any ideas? Another question - is it possible to create multiple band of the same band type, e.g., 2 detail bands? Basically, I want each detail band to hold certain fields and has its own band properties. Thanks in advance for your responses. Henry Link to comment Share on other sites More sharing options...
mmastrangelo Posted January 17, 2008 Author Share Posted January 17, 2008 Henry, I also identified that as the infinite while loop. This behavior has been very problematic for us as we allow users to customize their own reports in a production environment. To address this, I have created a forked version of JRVerticalFiller that implements a tolerance level of 100 max fill attempts. This seems to have greatly reduced the occurrences of the infinite loop. To implement this, the code snippet changes as follows: Code:while (band.willOverflow()){ fillPageBreak(false, evaluation, evaluation, true); printBand = band.fill(columnFooterOffsetY - offsetY - band.getHeight()); fillBand(printBand); offsetY += printBand.getHeight(); loopCount++; if (loopCount > MAX_FILL_ATTEMPTS) { throw new JRException("Max page band fill attempts exceeded"«»); }} Ultimately, it would be nice if this behavior was built into the JasperReports engine. The MAX_FILL_ATTEMPTS constant could become an optional parameter. Hope this helps. Link to comment Share on other sites More sharing options...
hszetu Posted January 17, 2008 Share Posted January 17, 2008 Thanks Matt for the snippet, that really helps. I would agree with you that this should be built right into the JasperReports engine;-) Henry Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now