Re: Class Instantiation Question
- From: "Larry Serflaten" <serflaten@xxxxxxxxxxxxxx>
- Date: Fri, 7 Apr 2006 07:26:48 -0500
"Karl E. Peterson" <karl@xxxxxxxx> wrote
If a class is instantiated at the function level, will the class be
disposed of when execution of the function ends?
<chuckle>
The correct answer is, "nobody knows."
Is that the correct answer? I would have thought the correct answer
would be no, if the system has to clean it up it will be finalized:
[ Excerpt from http://msdn.microsoft.com/msdnmag/issues/1100/gci/ ]
On the surface, finalization seems pretty straightforward: you create an object and when the object is collected, the object's
Finalize method is called. But there is more to finalization than this.
When an application creates a new object, the new operator allocates the memory from the heap. If the object's type contains a
Finalize method, then a pointer to the object is placed on the finalization queue.
[ ... During finalization ...]
The garbage collector scans the finalization queue looking for pointers to these objects. When a pointer is found, the pointer
is removed from the finalization queue and appended to the freachable queue (pronounced "F-reachable"). The freachable queue is
another internal data structure controlled by the garbage collector. Each pointer in the freachable queue identifies an object
that is ready to have its Finalize method called.
LFS
.
- Follow-Ups:
- Re: Class Instantiation Question
- From: Karl E. Peterson
- Re: Class Instantiation Question
- References:
- Class Instantiation Question
- From: Scott H
- Re: Class Instantiation Question
- From: Karl E. Peterson
- Class Instantiation Question
- Prev by Date: Re: gravity problem
- Next by Date: Re: How to use TextStream object
- Previous by thread: Re: Class Instantiation Question
- Next by thread: Re: Class Instantiation Question
- Index(es):
Relevant Pages
|