Does setting the Home and Object stubs to null from an EJB client improve performance?

Nick Minutello

No, not really.

If your appserver uses JRMP, then it *might* mean that your serverside objects (EJB's) get garbage collected sooner. However, it depends on the appserver's lifecycle management. Since IIOP is mandated in the EJB spec (and IIOP does not support distributed garbage collection) then most appservers probably rely on a different strategy for object lifecycle management.

If you ARE using JRMP, then the client-side garbage collection of the stubs (which can be accelerated by setting references to null) can reduce the network load (as the stubs sit there pinging the server objects to keep them alive).

However, I dont see that much of an improvement in performance to warrant setting stubs to null when you are done with them.

In fact, you will get better performance by *caching* your home stubs (these are always slow to look up). Check out the Home Factory pattern at http://www.theserverside.com/home/thread.jsp?thread_id=7931