andrey_nado Posted January 16, 2008 Share Posted January 16, 2008 Hi! I'am working on Tomcat 4 and using JasperReports 1.3.4.Some of my reports produce java.lang.OutOfMemoryError on report export stage, most often when exporting to RTF format. Filling of the reports works fine. I'm using JRFileVirtualizer. Reports which generate OutOfMemoryError do not have a lot of data rows but they deal with large images (up to 2 Mbytes). Could it be a reason? When I look at the virtualizer's temporary files, I see no files with size more than 20 kbytes. None of these files is capable to store my images. Are images kept in memory? I specified cache size to 1 (one page) and this did not help. Thanks for you help, Andrey Link to comment Share on other sites More sharing options...
lucianc Posted January 16, 2008 Share Posted January 16, 2008 andrey_nado wrote:Some of my reports produce java.lang.OutOfMemoryError on report export stage, most often when exporting to RTF format. Filling of the reports works fine.I'm using JRFileVirtualizer. Reports which generate OutOfMemoryError do not have a lot of data rows but they deal with large images (up to 2 Mbytes). Could it be a reason? Might be. However, by looking at the code is seems that the RTF exporter only loads a single image in memory at a time, so this might not be the problem. We would need to replicate such an issue to unerringly identify the cause. When I look at the virtualizer's temporary files, I see no files with size more than 20 kbytes. None of these files is capable to store my images. Are images kept in memory? Cached images are kept in memory (and not virtualized). How do your images look like (in JRXML)? Regards,Lucian Link to comment Share on other sites More sharing options...
andrey_nado Posted January 16, 2008 Author Share Posted January 16, 2008 Below is an example of JRXML-code. $V{path_to_img} is a string variable with full path to image file. Code:<image vAlign="Top" hAlign="Left" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self"> <reportElement x="70" y="120" width="470" height="500" key="image-1"> <printWhenExpression><![CDATA[new Boolean($P{model_eye_chart}!=null)]]></printWhenExpression> </reportElement> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <graphicElement stretchType="NoStretch"/> <imageExpression class="java.lang.String"><![CDATA[$V{path_to_img}]]></imageExpression></image> Link to comment Share on other sites More sharing options...
andrey_nado Posted January 16, 2008 Author Share Posted January 16, 2008 BTW, is there any difference (at report exporting stage) between images come from files (via string image expressions) and database (via InputStream expressions)? Link to comment Share on other sites More sharing options...
lucianc Posted January 16, 2008 Share Posted January 16, 2008 andrey_nado wrote:BTW, is there any difference (at report exporting stage) between images come from files (via string image expressions) and database (via InputStream expressions)? Yes. Images having String expressions are cache be default, as opposed to images having any other type of expressions which are not. You should explicitly set isUsingCache="true" if you don't want them to be cached (which is of course the case if the image sources do not repeat). HTH,Lucian Link to comment Share on other sites More sharing options...
andrey_nado Posted January 17, 2008 Author Share Posted January 17, 2008 I set explicitly isUsingCache="false" to <image> tag. Now I see that page with image is fully serialized into temporary file (file length is about 300K). But exporting to RTF still causes OutOfMemoryError when export routine achieves problem page. Is there any solutions you can recommend? I know about java's memory limit option. I noticed that Tomcat restarting removes this error for a little time, but error raises again soon after restarting. Could some memory leak exist in JasperReports engine? Link to comment Share on other sites More sharing options...
andrey_nado Posted January 17, 2008 Author Share Posted January 17, 2008 I also want to notice that PDF export works for the same JasperPrint instance (size of the source image is the same too). Link to comment Share on other sites More sharing options...
lucianc Posted January 17, 2008 Share Posted January 17, 2008 andrey_nado wrote:Is there any solutions you can recommend? I know about java's memory limit option.I noticed that Tomcat restarting removes this error for a little time, but error raises again soon after restarting. Could some memory leak exist in JasperReports engine? I don't think there's much we can do without actually replicating the issue. Without seeing and understanding what happens, we cannot provide a solution or speculate on possible memory leaks. So if you can provide a complete way of replicating this, we'd try/debug/profile the code and determine where's the problem. Also, you could at least post the code you're using to export to RTF so that we are sure that you're not doing anything wrong yourself. Regards,Lucian Link to comment Share on other sites More sharing options...
andrey_nado Posted January 21, 2008 Author Share Posted January 21, 2008 We have solved this problem. In fact we were using our customized version RTF exporter class (based on JRRtfExporter code) due to bad quality of native exporter (as of version 1.3.1). Now I tried newer version of JRRtfExporter (v1.3.4) and found it acceptable. Thanks for you answers, I didn't know about "static image cache" issue before. Andrey 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