Lifetime Leases

Objects that derive from System.MarshalByRef don’t live in memory forever. We stated earlier in this chapter that these objects have a default idle period of 5 minutes, after which time the instance will be released. A new instance will be created to service future client requests. The .NET remoting system uses a system of leases to control the lifetime of MarshalByRefObject (MBR) objects.

A lease defines the amount of time that an MBR object will be held in memory before the .NET remoting system releases the instance freeing the resources it consumes. Leases are used by the remoting server to ensure that objects not currently in use are marked for garbage collection.

When a new instance of a server-activated type is created, the ...

Get C# for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.