5 Replies Latest reply on Jul 31, 2009 8:19 PM by Arbi Sookazian

    Is using Bijection - @Out and @In expensive?

    Tariq Ahsan Newbie

      I was told that it is recommended to avoid using @Out and @In in passing object as it would be expensive in terms of memory usage. Is this correct? What would be more efficient - passing an object parameter of a class method or Outjecting the object?


        • 1. Re: Is using Bijection - @Out and @In expensive?
          Stuart Douglas Master

          Expensive is relative. It could be expensive in terms of memory if you were outjecting lots of unnecessary objects to a long lived scope such as the session scope, but otherwise no.


          Directly passing an object to a method should always be the fasted way of passing an object to a method, as it involves less JVM instructions than setting an instance variable and then invoking a method.


          The question you should be interested in is not which way is fastest, but if using injection/outject would provide an acceptable level of performance, which it should for most things. The main exception to this is loops where you will be making repeated invocations on a seam component, in this situation the interceptor overhead can kill performance.

          • 2. Re: Is using Bijection - @Out and @In expensive?
            Tariq Ahsan Newbie

            Thanks for the reply. I am instantiating a Seam componenet which is of EVENT scopetype in the caller program and executing it's method. I am outjecting an Entity POJO from the caller and injecting it in the Seam component instead of passing it as parameter in the method. Is this a more preferred way?

            • 3. Re: Is using Bijection - @Out and @In expensive?
              Arbi Sookazian Master

              When you're talking about heap memory usage/allocation in the JVM, you need to make the distinction of what type of components you're using.  Stateful, stateless, or both?  There is no SFSB pool in the EJB container but there is one for SLSBs.  Passivation/activation (serialization to/from disk) applies to SFSBs, not SLSBs, to save memory.  How many clients are using your app, internal or external facing, etc.  Do you have a cluster?


              Recently it was pointed out not to overuse outjection in order to maintain loose coupling of components.  Also remember that injection via @In occurs prior to any business method call in your component unless you use @BypassInterceptors.

              • 4. Re: Is using Bijection - @Out and @In expensive?
                Ingo Jobling Master

                I would pass the Entity as a parameter to the method call.  Much simpler and also easier to debug.

                • 5. Re: Is using Bijection - @Out and @In expensive?
                  Arbi Sookazian Master

                  Ingo Jobling wrote on Jul 31, 2009 03:17:


                  I would pass the Entity as a parameter to the method call.  Much simpler and also easier to debug.



                  good point.