Home > .NET Framework > Resurrection in .NET

Resurrection in .NET

I was asked in one of the interviews about resurrection:
I knew what it meant but was not able to explain it, So I just picked this from Jeffrey’s article on MSDN magazine.
This should help me put it into words the next time.
 
"When an application is no longer accessing a live object, the garbage collector considers the object to be dead. However, if the object requires finalization, the object is considered live again until it is actually finalized, and then it is permanently dead. In other words, an object requiring finalization dies, lives, and then dies again. This is a very interesting phenomenon called resurrection. Resurrection, as its name implies, allows an object to come back from the dead.
I’ve already described a form of resurrection. When the garbage collector places a reference to the object on the freachable queue, the object is reachable from a root and has come back to life. Eventually, the object’s Finalize method is called, no roots point to the object, and the object is dead forever after. But what if an object’s Finalize method executed code that placed a pointer to the object in a global or static variable?"
 
 
I also remember one of the uses of resurrection is an object pool, where you do not allow objects (which are expensive to create) to be Garbage Collected. I guess I read this in Applied Microsoft .NET Framework Programming, If I am right.
Advertisements
Categories: .NET Framework
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: