[omniORB] Garbage collection

Stefan Seefeld seefeld@sympatico.ca
Wed, 14 Feb 2001 16:28:11 -0500


Mike Mascari wrote:
> 
> Hello.
> 
> I have a session-oriented application which uses an object factory to
> generate a transient session-specific object for each client connection. I
> have read Michi Henning & Steve Vinoski's book regarding the various
> tecniques of garbage collecting the servants when a client dies
> unexpectedly, but none seem too pleasing. One of the methods they refer to
> is the use of ORB proprietary extensions that allow the server code to
> detect when a connection from a client goes down. Does omniORB have such an
> extension? If not, what do people find the most reasonable way to garbage
> collect session-specific servants after a client dies?


you may run a ping() from within your session object that makes sure the
client is still alive, or you may just record the last time any data was
exchanged.
Second, you need to associate all server side objects that are created on
behalf of the client, so you can destroy them all when the client has died.
The technique we use for this is to allocate POAs per client, and activate
all objects for that client with one of the POAs that are in use for it.
This avoids the bookkeeping, as the POA will take down all objects it manages,
if it is destroyed. Of course, you then need to use the PortableServer::RefCountBase
to bind the servant lifetime to the object lifetime...

Regards,	Stefan