CHAPTER 18 592 THE .NET REMOTING LAYER (Cedant web hosting)

CHAPTER 18 592 THE .NET REMOTING LAYER Source Code The CAOCarGeneralAsm, CAOCarProviderServer, and CAOCarProviderClient projects are located under the Chapter 18 subdirectory. The Lease-Based Lifetime of CAO/WKO-Singleton Objects As you have seen, WKO types configured with single call activation are alive only for the duration of the current method call. Given this fact, WKO single call types are stateless entities. As soon as the current invocation has completed, the WKO single call type is a candidate for garbage collection. On the other hand, CAO types and WKO types that have been configured to use singleton activation are both, by their nature, stateful entities. Given these two object configuration settings, the question that must be asked is, how does the server process know when to destroy these MBR objects? Clearly, it would be a huge problem if the server machine garbage-collected MBR objects that were currently in use by a remote client. If the server machine waits too long to release its set of MBR types, this may place undo stress on the system, especially if the MBR object(s) in question maintain valuable system resources (database connections, unmanaged types, and whatnot). The lifetime of a CAO or WKO-singleton MBR type is governed by a lease time that is tightly integrated with the .NET garbage collector. If the lease time of a CAO or WKO-singleton MBR type expires, the object is ready to be garbage-collected on the next collection cycle. Like any .NET type, if the remote object has overridden System.Object.Finalize() (via the C# destructor syntax), the .NET runtime will indeed trigger the finalization logic. The Default Leasing Behavior CAO and WKO-singleton MBR types have what is known as a default lease, which lasts for five minutes. If the runtime detects five minutes of inactivity have passed for a CAO or WKO-singleton MBR type, the assumption is that the client is no longer making use of the object and therefore the remote object may be garbage-collected. However, when the default lease expires, this does not imply that the object is immediately marked for garbage collection. In reality, there are many ways to influence the behavior of the default lease. First and foremost, anytime the remote client invokes a member of the remote CAO or WKOsingleton MBR type, the lease is renewed back to its five-minute limit. In addition to the automatic client-invocation-centric renew policy, the .NET runtime provides three additional alternatives: *.config files can be authored that override the default lease settings for remote objects. Server-side lease sponsors can be used to act on behalf of a remote object whose lease time has expired. Client-side lease sponsors can be used to act on behalf of a remote object whose lease time has expired. We will check out these options over the next several sections, but for the time being let s examine the default lease settings of a remote type. Recall that the MarshalByRefObject base class defines amember named GetLifetimeService(). This method returns a reference to an internally implemented object that supports the System.Runtime.Remoting.Lifetime.ILease interface. As you would guess, the ILease interface can be used to interact with the leasing behavior of a given CAO or WKO-singleton type. Here is the formal definition: public interface ILease { TimeSpan CurrentLeaseTime { get; }
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.

Leave a Reply