Use pass by value if possible. See warning at bottom of explanation.
Pass-by-value versus pass-by-reference
(NoLocalCopies)
Short description: The
EJB 1.1 specification states that method calls are to be pass-by-value. Pass-by-value means that for every remote method call, the parameters are copied onto the stack before the call is made. This can be expensive. It is possible to specify pass-by-reference, which passes the original object reference without making a copy of the object.
Actual benefit observed: If the EJB client and EJB server are installed in the same WebSphere Application Server instance, specifying pass-by-reference can improve performance up to 50%.
When to try adjusting: Pass-by-reference helps performance only in the case where non-primitive object types are being passed as parameters. Therefore, int and floats are always copied, regardless of the call model.
WARNING: Pass-by-reference can be dangerous and can lead to unexpected results. If an object reference is modified by the remote method, the change might be seen by the caller.