Home > Guides > Programming > .NET and Windows Programming

Toggle Open Guide Table of ContentsGuide Contents

Close Table of ContentsGuide Contents

Close Table of Contents

Remoting: Lifetimes and Leases

Last updated Jul 29, 2005.

An object's lifetime is the total amount of time that it spends in memory. In .NET, all remote objects, whether they're server activated or client activated, have a default lifetime. Server activated single call objects, of course, are destroyed after satisfying a single client request. Singleton objects and client activated objects persist for a period of time. The server application domain controls the lifetime of a remote object. It is instructive to understand why this is so.

If you're familiar with COM and DCOM, you will remember that an object would remain in memory as long as a client maintained a reference to it. This worked well in simple scenarios, but in complex applications the reference counting was quite involved and objects tended to be destroyed prematurely because the reference count unexpectedly went to 0, or left in memory indefinitely because the reference count was not decremented correctly. In addition, constant pinging between client and server resulted in high network traffic volumes. In short, reference counting is difficult to implement and therefore unreliable, and uses a lot of network bandwidth.

In a distributed application, it's important to have some method of automatically destroying an object on the server and reclaiming its memory. Otherwise, unexpected disconnections and improper programming on the client can cause server objects to remain in memory indefinitely, using valuable resources and eventually leading to a system crash.

In .NET, the server controls a remote object's lifetime using a combination of leases, a lease manager, and some number of sponsors.

Discussions

Copies of the array?
Posted Dec 23, 2008 03:40 PM by luige21
1 Replies
Hi
Posted Dec 5, 2008 05:10 AM by ajay2000bhushan
2 Replies
You have no clue.
Posted Jun 10, 2008 03:28 PM by theinternetmaster
1 Replies

Make a New Comment

You must log in in order to post a comment.

Related Resources

Jim Mischel"Highly unlikely" does not mean "impossible"
By Jim MischelJuly 18, 2009 No Comments

One of my programs crashed the other day in a very unexpected place.  A call to System.Threading.ConcurrentQueue.TryDequeue (from the Parallel Extensions to .NET) resulted in an OverflowException being thrown.  Investigation revealed a pretty serious bug in the System.Random constructor.

It's Here; Put Away Your Pre-Conceptions on What an OS Must Be: Part II
By John TraenkenschuhMay 24, 2009 No Comments

In the last blog in this series, Traenk relates his first experiences with computers and with coding.  But now, some years have passed. . .

It's Here; Put Away Your Pre-Conceptions on What an OS Must Be: Part I
By John TraenkenschuhMay 24, 2009 No Comments

Traenk relates his past experience with Operating Systems that goes back 25 years, ok, more than that but he ain't tellin'

See More Blogs

Informit Network