1 Reply Latest reply on May 27, 2010 3:33 PM by Wang Liyu

    Memory leak with @Out in SLSB

    Wang Liyu Apprentice

      I have a SLSB that needs to outject some conversation attributes, and I found even after the conversation end, the attributes are still there. I checked the code, Seam released the attributes from conversation context, but SLSB has the references to these attributes, so JVM still consider those attributes are using and can't release them, in the org.jboss.seam.core.BijectionInterceptor, it does call component.disinject( invocation.getTarget() ); at the end, but that method only release the @In attributes, for @Out attributes, it will not clean, and SLSB will be reused for different client, so this could be lead to a potential memory leak.


      I'm wondering does anybody solved this kind of problems before? also as I know the CDI doesn't reset @Inject attributes in the managed bean, so if managed bean is stateless and not bound to context (for example the Stateless Session Bean), it might be a memory leak too (I haven't test that yet, but I'll test it when I have free time).


        • 1. Re: Memory leak with @Out in SLSB
          Wang Liyu Apprentice
          Found 2 ways work around this problem:
          1> don't declare any @Out in the SLSB, use ScopeType.CONVERSATION.getContext().set("variable", variable); since the veriable is declared within the method, it will release the reference when returning from the method, this will avoid problem and performance is better than @Out.

          2> Add @In(required=false) before the @Out, the @In just tell Seam, release this attribute reference after the method returns, this will register the same attributes into both Inject and Outject attribute list, performance is worse than previous one.

          Actually in the component.disinject method, it should check if the target component is a STATELESS Bean, if it is, it should release the reference of @Out attribute list.


          I'll add this to the gotcha list