Home
Analytics
Am I producing "memory leaks"? Using BIRT 2.6.1
KartoffelK
Hello,<br />
<br />
I am testing the BIRT Engine 2.6.1 and have a little problem/question.<br />
<br />
Here a little code example how I am using BIRT.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
EngineConfig config = null;
ReportEngine engine = null;
PDFRenderOption option = null;
for (int i = 0; i < 10; ++i)
{
long d = System.currentTimeMillis();
if (config == null)
{
System.out.println("make config");
config = new EngineConfig();
config.setEngineHome("c:/BIRT_2.6.1_test/Report-Engine");
config.setResourcePath("c:/BIRT_2.6.1_test/rsc");
}
if (engine == null)
{
if (config != null)
{
System.out.println("make engine");
engine = new ReportEngine(config);
}
}
try
{
IReportRunnable design = engine.openReportDesign("c:/BIRT_2.6.1_test/rpts/test.rptdesign");
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
if (option == null)
{
System.out.println("make option");
option = new PDFRenderOption();
}
option.setOutputFormat("pdf");
option.setOutputFileName("c:/BIRT_2.6.1_test/output/test.pdf");
task.setRenderOption(option);
task.run();
task.close();
System.out.println("finished >> " + (System.currentTimeMillis()-d));
Thread.sleep(1000);
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
</pre>
<br />
After each run in the for loop, the memory is growing up for about 2-3MB. But this memory will never be de-allocated. Also when I'm executing the GC manually and also after waiting some minutes.<br />
<br />
Do I forget to destroy some resources, to close any option or something like that? Because it could normally not be, that the memory will grow up that way.<br />
<br />
<br />
Best regards,<br />
KK
Find more posts tagged with
Comments
KartoffelK
Hello,<br />
<br />
I forgot a little completion, here the output from my program:<br />
<br />
<blockquote class='ipsBlockquote' ><p>
make config<br />
make engine<br />
make option<br />
14.02.2011 16:16:37 org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadDriverExtensions<br />
INFO: Found JDBC driverinfo extension: driverClass=org.apache.derby.jdbc.EmbeddedDriver, connectionFactory=null<br />
14.02.2011 16:16:37 org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager$DriverClassLoader addNewURL<br />
INFO: JDBCDriverManager: found JAR file drivers/mysql-connector-java-5.1.12-bin.jar. URL=bundleentry://40.fwk17870931/drivers/mysql-connector-java-5.1.12-bin.jar<br />
14.02.2011 16:16:37 org.eclipse.birt.report.data.oda.jdbc.Connection open<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@1f35e30 is opened<br />
14.02.2011 16:16:37 org.eclipse.birt.report.engine.layout.pdf.font.FontMappingManagerFactory loadFontMappingConfig<br />
INFO: load font config in bundleentry://57.fwk17870931/fontsConfig.xml cost 16ms<br />
14.02.2011 16:16:37 org.eclipse.birt.report.engine.layout.pdf.font.FontMappingManagerFactory$2 run<br />
INFO: register fonts in C:/WINNT/fonts cost:0ms<br />
14.02.2011 16:16:37 org.eclipse.birt.report.engine.layout.pdf.font.FontMappingManagerFactory$2 run<br />
INFO: register fonts in C:/windows/fonts cost:62ms<br />
14.02.2011 16:16:37 org.eclipse.birt.report.engine.layout.pdf.font.FontMappingManagerFactory loadFontMappingConfig<br />
INFO: load font config in bundleentry://57.fwk17870931/fontsConfig_win32.xml cost 0ms<br />
14.02.2011 16:16:37 org.eclipse.birt.report.engine.layout.pdf.font.FontMappingManagerFactory loadFontMappingConfig<br />
INFO: load font config in bundleentry://57.fwk17870931/fontsConfig_pdf.xml cost 0ms<br />
14.02.2011 16:16:38 org.eclipse.birt.report.data.oda.jdbc.Connection close<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@1f35e30 is closed<br />
finished >> 5297<br />
14.02.2011 16:16:41 org.eclipse.birt.report.data.oda.jdbc.Connection open<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@e6f970 is opened<br />
14.02.2011 16:16:41 org.eclipse.birt.report.data.oda.jdbc.Connection close<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@e6f970 is closed<br />
finished >> 500<br />
14.02.2011 16:16:43 org.eclipse.birt.report.data.oda.jdbc.Connection open<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@1adff28 is opened<br />
14.02.2011 16:16:43 org.eclipse.birt.report.data.oda.jdbc.Connection close<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@1adff28 is closed<br />
finished >> 453<br />
14.02.2011 16:16:46 org.eclipse.birt.report.data.oda.jdbc.Connection open<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@fdf48d is opened<br />
14.02.2011 16:16:46 org.eclipse.birt.report.data.oda.jdbc.Connection close<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@fdf48d is closed<br />
finished >> 562<br />
14.02.2011 16:16:48 org.eclipse.birt.report.data.oda.jdbc.Connection open<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@ca1465 is opened<br />
14.02.2011 16:16:48 org.eclipse.birt.report.data.oda.jdbc.Connection close<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@ca1465 is closed<br />
finished >> 438<br />
14.02.2011 16:16:51 org.eclipse.birt.report.data.oda.jdbc.Connection open<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@12a3766 is opened<br />
14.02.2011 16:16:51 org.eclipse.birt.report.data.oda.jdbc.Connection close<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@12a3766 is closed<br />
finished >> 391<br />
14.02.2011 16:16:53 org.eclipse.birt.report.data.oda.jdbc.Connection open<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@15fb94a is opened<br />
14.02.2011 16:16:53 org.eclipse.birt.report.data.oda.jdbc.Connection close<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@15fb94a is closed<br />
finished >> 391<br />
14.02.2011 16:16:55 org.eclipse.birt.report.data.oda.jdbc.Connection open<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@16eeaaa is opened<br />
14.02.2011 16:16:56 org.eclipse.birt.report.data.oda.jdbc.Connection close<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@16eeaaa is closed<br />
finished >> 437<br />
14.02.2011 16:16:58 org.eclipse.birt.report.data.oda.jdbc.Connection open<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@b8584d is opened<br />
14.02.2011 16:16:58 org.eclipse.birt.report.data.oda.jdbc.Connection close<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@b8584d is closed<br />
finished >> 375<br />
14.02.2011 16:17:00 org.eclipse.birt.report.data.oda.jdbc.Connection open<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@92949f is opened<br />
14.02.2011 16:17:00 org.eclipse.birt.report.data.oda.jdbc.Connection close<br />
WARNUNG: JDBC connection: com.mysql.jdbc.JDBC4Connection@92949f is closed<br />
finished >> 328<br /></p></blockquote>
<br />
The part above in the for loop should be a function. Here it is only part of a little test application.
garyxue
Memory growth itself does not necessarily mean a resource leak. A couple things to keep in mind: (1) BIRT engine has some internal caches that persist between tasks; the memory used by these caches may increase until they reach certain size. (2) Java GC does not always reclaim all memory, as long as free heap memory remains available.
A couple things that I'd like to suggest that you try to further diagnose this issue:
(1) Try a simple report (perhaps one of the simply listing reports included in BIRT samples)
(2) Run with a smaller JRE cache size (e.g. 256MB) and put your report run in an infinite loop. If the memory use eventually stabilizes there is probably not a resource leak.
regards,
Gary Xue
KartoffelK
Dear Gary,
thanks for your reply!
I tried to use an existing report file and let it create everytime the same pdf file in an infinite loop. The result after a few hours: about 328mb and no more. Here seems to be the end of the road.
Is it true that BIRT uses all available memory and only if this is full, the engine will clean up?
garyxue
<blockquote class='ipsBlockquote' data-author="'KartoffelK'" data-cid="73375" data-time="1297797034" data-date="15 February 2011 - 12:10 PM"><p>
Dear Gary,<br />
...<br />
<br />
Is it true that BIRT uses all available memory and only if this is full, the engine will clean up?<br /></p></blockquote>
<br />
No. BIRT's use of memory is limited and is related to the complexity of the report and its volume data. Java's GC however generally favor using available heap memory over garbage collection. So it's not uncommon to see a Java program use up most of the available heap before JVM starts aggressive garbage collection.<br />
<br />
-<br />
Gary
vhuynen
<blockquote class='ipsBlockquote' ><p>Hello,<br />
<br />
A simple solution to avoid this memory problem :<br />
<a class='bbc_url' href='
http://lbroudoux.wordpress.com/2011/03/06/limit-birt-heap-usage-to-avoid-outofmemoryerror/'>limit-birt-heap-usage-to-avoid-outofmemoryerror</a><br
/>
<br />
Solution used in <a class='bbc_url' href='
http://www.trailplans.com'>http://www.trailplans.com</a><br
/>
<br />
Vincent</p></blockquote>