
Signature
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
Hi Chris,
Thanks for the reply. Here is what i understand from your explanation.
1. The finalization queue will keep on adding references to the same object
to match ReRegisterForFinalize calls on the same object.
2. SuppressFinalize will set the "run my finalizer bit" in the obj. When GC
reaches a reference
in the finalization queue, it checks this bit and if the bit is not set,
wont move that to the f-reachable. GC would set the bit on the object so
that the object references pending in the finalization queue will be moved
to f-reachable and eventually the Finalize method will be called.
Please tell me if i understood it right.
Thanks
Priyesh
> Hi Priyesh
>
> No, there's no reference counting involved on the finalization queue. SuppressFinalize(obj) affects the first reference to obj on the queue, so
calling it several times in a row has
> no added effect, regardless of how many times obj is on the queue.
>
> The finalization queue doesn't have a seperate structure, rather a (strong) reference to the object in memory. In the object's header is the
"run my finalizer" bit. When
> suppressis called, the GC scans the queue from the front and and stops at the first reference to obj (when called again, it starts from the front of
the queue again). That bit is set
> in the header of the object obj points to. When reregister is called on obj, another reference to the object is placed at the end of the (FIFO)
queue), so Suppress will never reach
> past the first reference (which is why, as Richter states, you cannot balance out several calls to Rereg with Suppress).
>
> The only I can think of to remove all pending finalization requestsis to have a suppress after every call to reregister. Short of that, maybe
setting a flag in your finalizer to say
> your object has already been finalized would remove redundant cleanup, but wouldn't stop the object from being put on the queue.
>
[quoted text clipped - 15 lines]
> >NNTP-Posting-Host: wireless-216-222-33-194.boi.velocitus.net 216.222.33.194
> >Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12
.phx.gbl
> >Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.clr:11372
> >X-Tomcat-NG: microsoft.public.dotnet.framework.clr
[quoted text clipped - 110 lines]
> >message are best directed to the newsgroup/thread from which they
> >originated.
rights. Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
>
> Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
"Chris Lyon [MSFT]" - 27 Jul 2004 23:12 GMT
Hi Priyesh
1. Yes, that's right.
2. Yes. SuppressFinalizer sets the "run my finalizer" bit to false, and that reference is removed from the queue, at which point the GC resets the bit to true. Now when the next
reference to the same object is encountered on the queue, the object is moved to the f-reachable queue where its finalizer gets run.
I think we're on the same page now :)
-Chris
--------------------
>Hi Chris,
>Thanks for the reply. Here is what i understand from your explanation.
[quoted text clipped - 202 lines]
>message are best directed to the newsgroup/thread from which they
>originated.

Signature
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
Priyesh - 28 Jul 2004 00:10 GMT
Thankyou. I really appreciate it.
> Hi Priyesh
>
> 1. Yes, that's right.
>
> 2. Yes. SuppressFinalizer sets the "run my finalizer" bit to false, and that reference is removed from the queue, at which point the GC resets the
bit to true. Now when the next
> reference to the same object is encountered on the queue, the object is moved to the f-reachable queue where its finalizer gets run.
>
[quoted text clipped - 206 lines]
> >>
> >rights. Use of included script samples are subject to the terms specified
at
> >> http://www.microsoft.com/info/cpyright.htm
> >>
> >> Note: For the benefit of the community-at-large, all responses to this
> >message are best directed to the newsgroup/thread from which they
> >originated.
rights. Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
>
> Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.