christiaan_se
-
Posts
51 -
Joined
-
Last visited
Content Type
Forum
Downloads
Featured Visualizations
Knowledge Base
Documentation (PDF Downloads)
Blog
Documentation (Test Area)
Documentation
Dr. Jaspersoft Webinar Series
Security Advisories
Events
Profiles
Posts posted by christiaan_se
-
-
Hi,
we are using jasperreports 1.3.2 and one of our testers noticed that after previewing a report multiple times he got an OutOfMemoryException. Running the following simple testcase we indeed notice that the memory usage keeps increasing and will result in OOM. It shouldn't, right?
Code:
for(int i = 0; i < 10000; i++) {
JRViewer viewer = new JRViewer(jasperPrint);
JFrame frame = new JFrame();
frame.setPreferredSize(new Dimension(500, 500));
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(viewer, BorderLayout.CENTER);
//JasperViewer.viewReport(jasperPrint, false);
frame.setVisible(true);
frame.setVisible(false);
//clear() reduces memory growth, but still increases
viewer.clear();
System.out.println("" + i + " - "+ calcMemoryUsage());kind regards,
Christiaan
-
Hi,
I think you need to use
JRDesignImage.setUsingCache(true);
otherwise the image will be copied everytime it is used.
kind regards,
Christiaan
-
Hi,
any comments from the Jasper team on this? We are considering doing the same update.
kind regards,
Christiaan
-
Yes sorry about that (and the late reply). It's just example code, not fully functional. The idea is that you provide a custom datasource for both parent and child. As soon next is being called you store that info in an attribute so the child CustomDataSource can easily access this.
Code:
public class CustomDataSource implements JRDataSource {
private CustomDataSource parentDatasource = null;
private Object currentObject = null;
public ChildDataSource (ParentDataSource parentDatasource) {
super();
this.parentDatasource = parentDatasource;
}
public Object getFieldValue(JRField field) throws JRException {
if(parentDatasource != null) {
Object parentObject = parentDatasource.getCurrentRow();
//now use parentObject to get parent info
}
//use currentObject to retrieve info
}
public boolean next() throws JRException {
//process next data
//assign data to currentObject
}
public Object getCurrentObject() {
return currentObject();
}
}hope this helps,
Christiaan
-
Hi,
you can write a custom datasource which has access to the parent datasource:
Code:
public class ChildDataSource implements JRDataSource {
private JRDataSource parentDatasource = null;
public ChildDataSource (ParentDataSource parentDatasource) {
super();
this.parentDatasource = parentDatasource;
}
public Object getFieldValue(JRField field) throws JRException {
Object parentObject = parentDatasource.getCurrentRowObject();
....
}
} -
Hi,
not sure what you mean, are you talking about opening and modifying an existing pdf file or do you want to generate a pdf file based on a jasper reports. JasperReports is not meant for the first option, you should use something like the iText library.
kind regards,
Christiaan
-
hi,
our users have a special request for printing "watermarks", for instance an image or the text "concept" printed over the complete page. I've tried using the background band for this, but in order to make it visible I need to make sure all my elements on the report are transparent which is not feasible. I would like to make a request for a foreground band (preferrably with a transparancy value) which behaves the same as the background band except for the fact that it is painted over the existing elements.
kind regards,
Christiaan
-
Thnx for the reply. I actually don't have any experience with POI at the moment, but I probably need to use it in the near future. I will keep you informed if I find a solution. I suppose you tried the quickguide explanation:
-
Hi,
I am using JasperReports 1.2.6 and I am currently encountering the already familiar issue that images are not exported to Excel. I read I should be using jexcelapi from the demos folder. However on the POI site I read that images are supported:
http://jakarta.apache.org/poi/hssf/quick-guide.html#Images
(btw, I also saw a newer version of POI than the one included with JasperReports is available).
Any chance that export of images to excel will be done with the default POI?
kind regards,
Christiaan
-
Hi,
in the constructor of JasperViewer there is boolean indicating whehter it should perform an exit on close.
With the viewer you can't view pdf files, you just view the jasper reports. To view pdf files you probably need to use something like JDIC or get a (commercial and most of the times pretty expensive) java implementation of a pdf viewer. There used to be a nice java-com bridge available (njawin) which is now commercially available (http://www.javain.com).
kind regards,
Christiaan
-
Hi Lucian,
thanks for the reply. I was actually under the wrong impression that the report generation process is streambased, so thats why I thought it was a memory leak. Unfortunately our users do need these kind of reports (not printed, but in pdf format), so I hope I can solve it with the heap space increase.
kind regards,
Christiaan
-
Hi,
I have a simple large report (200.000 record) where each record has a simple sub report of 500 records. Printing it results in a java.lang.OutOfMemoryError: Java heap space after printing 15.000 records. (I also noticed that after printing a couple of thousands or records things really start to slow down, but this is probably caused by this) I use a swapfilevirtualizer and have set Xmx256M When printing just the main report (so without subreport) this doesn't result in OutOfMemory.
I've attached a simple testcase to reproduce this.
It occurs at:
net.sf.jasperreports.engine.fill.JRVerticalFiller(net.sf.jasperreports.engine.fill.JRBaseFiller).fill(java.util.Map) line: 783
net.sf.jasperreports.engine.fill.JRVerticalFiller(net.sf.jasperreports.engine.fill.JRBaseFiller).fill(java.util.Map, net.sf.jasperreports.engine.JRDataSource) line: 666
net.sf.jasperreports.engine.fill.JRFiller.fillReport(net.sf.jasperreports.engine.JasperReport, java.util.Map, net.sf.jasperreports.engine.JRDataSource) line: 89
net.sf.jasperreports.engine.JasperFillManager.fillReport(net.sf.jasperreports.engine.JasperReport, java.util.Map, net.sf.jasperreports.engine.JRDataSource) line: 601
test.Test.main(java.lang.String[]) line: 37
[file name=testcaseoutofmem.zip size=3860]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/testcaseoutofmem.zip[/file]
Memory leak in JRViewer?
in Products
Posted
Hi Teodor,
thanks for the reply. This was actually a mistake in the testcase, in the application it was done properly. However, I replaced the code with below, and there is still the memory increase ending in an OoM exception.
kind regards,
Christiaan