Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 335850

Summary: Too many shutdown listeners -> java.lang.OutOfMemoryError: unable to create new native thread
Product: z_Archived Reporter: Tim <tim.warode>
Component: BIRTAssignee: Birt-Data-inbox <Birt-Data-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bluesoldier, wyan
Version: 2.5.2   
Target Milestone: 3.7.0   
Hardware: PC   
OS: Windows XP   
Whiteboard: Obsolete

Description Tim CLA 2011-01-31 09:55:36 EST
Build Identifier: 20100218-1602

Hi,

we have the BIRT report engine embedded in our RCP application. Our customers are facing random errors:

java.lang.OutOfMemoryError: unable to create new native thread 
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:597)
at org.eclipse.birt.data.engine.executor.DataSource$ShutdownListener.dataEngineShutdown(DataSource.java:92)
at org.eclipse.birt.data.engine.impl.DataEngineImpl.shutdown(DataEngineImpl.java:566)
at org.eclipse.birt.report.data.adapter.impl.DatRequestSessionImpl.shutdown(DataRequestSessionImpl.java:455)
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.shutdown(AbstractDataEngine.java:348)
at org.eclipse.birt.report.engine.executor.ExecutionContext.closeDataEngine(ExecutionContext.java:874)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:175)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:75)
at de.micronova.exam.reportmanager.job.ExportPDFReportJob.run(ExportPDFReportJob.java:236)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

when running a report.
I had a short look into it and saw that hundreds of org.eclipse.birt.data.engine.executor.DataSource instances are created through org.eclipse.birt.data.engine.executor.DataSourceFactory.getDataSource(String, Map, DataEngineSession). Each of those instances registers a org.eclipse.birt.data.engine.executor.DataSource.ShutdownListener with the same instance of the org.eclipse.birt.data.engine.api.DataEngine.
When the engine finally is shut down, each of those listeners tries to create a new thread which sometimes produces the error above (heavily depends on timing - I wasn't able to reproduce the error but I saw that hundreds of shutdown listeners are being registered).
Is this a general issue or is it just us doing something wrong?

Cheers,
Tim

Few more facts:
Birt Version 2.5.2.v20090925-7l9V7YFT0z0-DX3kf8ShK8
We are using a scripted data source.
We are using the org.eclipse.birt.report.engine.api.IRunAndRenderTask to run/render the design.
Output format is PDF. 

Reproducible: Couldn't Reproduce
Comment 1 Xiaoying Gu CLA 2011-02-09 01:26:36 EST
This issue should have been resolved in 2.6.1 release.

Would you please try again with the 2.6.1 release build?
Comment 2 Tim CLA 2011-02-11 03:20:29 EST
Unfortunately, upgrading to 2.6 is not an option for us at the moment. 
Is there any workaround possible?
Comment 3 Xiaoying Gu CLA 2011-02-24 20:24:25 EST
Since we no longer maintain the 2.5.x stream, please upgrade to the latest release.