1 Reply Latest reply on Jun 13, 2008 4:21 PM by norman

    Stateful Session Bean memory leak

    laurencekirk

      We have found that if a SFSB contains a reference to another SFSB (using @EJB or @In) , that the contained SFSB is never garbage collected, whereas the containing SFSB is removed and collected as expected.





      So in the example below testComponent is never garbage collected, but testHolder is removed and garbage collected as normal.
      This is using Seam 2.0.2.CR1 and JBoss 4.2.2.GA


      Name("testHolder")
      
      @Scope(ScopeType.CONVERSATION)
      
      @Stateful
      
      @AutoCreate
      
      public class TestHolder  implements TestHolderManager,Serializable {
      
      
              
      
       @EJB TestComponentManager testComponent;
      
      ....
      
      }
      
      
       and 
      
      
      @Name("testComponent")
      
      @Scope(ScopeType.CONVERSATION)
      
      @Stateful
      
      @AutoCreate
      
      public class TestComponent  implements TestComponentManager, Serializable{
      
      
      ...
      
      }
      
      




      As a work around we have an interceptor that ensures that all contained SFSBs have a remove method called when their holding SFSB is removed.


      Has anyone else experienced this ?

        • 1. Re: Stateful Session Bean memory leak
          norman

          There's a huge difference between @EJB and @In.   I find it hard to believe that two completely different mechanisms both suffer from the same memory problem.  Do your tools tell you who is holding the reference to the object?