Creation and destruction objects

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi to all,

I would like to know how .net manage the objects and what are the cicle of life of the objects...
Are the same this cicle, for the objects created in windows applications and for the web applications?

Any help will be grateful
Thank
Owatona
 
An object lives as long as there exists any references to it.
The garbage collector will every so often check all objects to see if they
are still referenced, and if not, release it and any other objects this
object references.

For web application things are slightly different.
The lifespan is still basically the same, but your "form" will terminate
once it is made and sent to the user, and the "application" will terminate
when there is no session holding it alive. Objects references will
therefore end and the objects will be released. You can store objects as
Session or Application variables to use accross pages and sessions.
 
Morten.... To be clear, an object is also eligible for garbage
collection
when is is unreachable, so two isolated objects can hold references to
each other (circular references) and still be marked for garbage
collection.

Regards,
Jeff
 
Back
Top