1 Reply Latest reply on Oct 6, 2008 1:27 PM by Pete Muir

    Outjection (@Out) and memory leaks

    parag talekar Newbie

      Why are @Out attributes not set to null after outjection?


      I see the following in BijectionInterceptor.java:


      45            component.inject( invocation.getTarget(), enforceRequired );
      46            Object result = invocation.proceed();            
      47            component.outject( invocation.getTarget(), enforceRequired );
      48            component.disinject( invocation.getTarget() );
      



      Now in Component.java called thru Component.disinject() then Component.disinjectAttributes():


      1604      for ( BijectedAttribute att: getInAttributes() )
      1605      {
      1606         if ( !att.getType().isPrimitive() )
      1607         {
      1608            att.set(bean, null);
      1609         }
      1610      }
      



      I don't see where it a sets the @Out attributes to null, am I missing something here?


      Consider the following SLSB from the Seam examples:


      @Stateless
      @Name("authenticator")
      public class AuthenticatorAction implements Authenticator, Serializable
      {
         @PersistenceContext EntityManager em;
      
         @Out(required=false, scope = SESSION)
         private User user;
      
         public boolean authenticate()
         {
            List results = em.createQuery("select u from User u where u.username=#{identity.username} and u.password=#{identity.password}")
                  .getResultList();
      
            if ( results.size()==0 )
            {
               return false;
            }
            else
            {
               user = (User) results.get(0);
               return true;
            }
         }
      
      }




      Since authenticator is stateless the container will manage it thru pooled instances, so if the @Out attribute (user) is not set to null after invocation of authenticate() it will not be eligible for garbage collection even after the session is destroyed. Please correct me if I'm wrong.


      Thanks in anticipation.