Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-3873

Memory leak using EJB transactions and jBpm contexts


    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1.1.GA
    • Fix Version/s: The future
    • Component/s: BPM, Core, EJB3
    • Labels:
    • Workaround Description:

      Use BMT instead of CMT. The test application shows how to do this.

      Use BMT instead of CMT. The test application shows how to do this.


      Our application had to survive a night with full load. On the next morning the heap was full of JbpmContext's.

      After looking at the source code of Seam and at the debug messages we came up with this hypothesis:

      • The SFSB EjbSynchronizations is placed in the event context, the Seam-JbpmContext-Component also lives in the event context.
      • Using EJB transactions, EjbSynchronizations is responsible for cleaning up the JbpmContext after the end of the transaction.
      • Unfortunately the event context ends BEFORE EjbSynchronizations has the chance to clean up the JbpmContext.

      Using BMT the transaction ends before the event context ends. Thus, the JbpmContext is cleaned up.

      We switch all our MDBs, EJB-timers, and Web-services from CMT to BMT and (after fixing some other leaks, e.g. a class loader issue in jBpm), we survived the night.

      I wrote a small test application that shows the memory leak and I will try to attach it to this issue.

      It is a Maven application that consists of

      • a Web-GUI to start the test and displays the results (http://localhost:8080/leak/)
      • a SFSB that sends 10 messages each to two queues (the standard queues A and B), waits a little bit, and does a gc
      • two MDBs, one with CMT, one with BMT, which uses Seam injection to access a jBpm-Context
      • an application scoped POJO that saves the contexts in a Set using a weak reference

      After executing the tests and the GC, the surviving references are displayed. You can see that the CMT references are not gs'ed whereas the BMT references are cleaned up. You can execute the test several times.

        Gliffy Diagrams


            Issue Links



                • Assignee:
                  tnfink Torsten Fink
                • Votes:
                  4 Vote for this issue
                  4 Start watching this issue


                  • Created: