[Mono-list] Garbage-collecting a remoting singleton object in a service?

Robert Jordan robertj at gmx.net
Mon Sep 4 06:08:35 EDT 2006

Andrés G. Aragoneses [ knocte ] wrote:
> Thanks for the answers Robert and Lluis. I was using the Disconnect 
> method but I was unsure if it was the thing I needed; in fact, it's a 
> bit strange that the "opposite" of Disconnect is Marshal, instead of 
> Connect, which I think is the method used by the other side (the 
> clients) if they don't use the Activator.GetObject() form.
> BTW, I am supposing that the garbage-collection of the client objects is 
> automatic because I store them as IClient objects, not as 
> MarshalByRefObject, am I right?

That's not the real reason why they are GCed. If an object
is casted to one of its interface it still remains the
same object.

If the client is implementing IClient while subclassing
MarshalByRefObject, the usual remoting lifetime constraints
will take effect.

You can control the lifetime (on the client) by overriding

The IClient proxy (on the server) is subject to be GCed after
it's removed from the hClients dictionary or after calling
RemotingServices.Disconnect on the singleton.


More information about the Mono-list mailing list