Willy Denoyette [MVP] <wi*************@telenet.bewrote:
Not sure what you mean here Jon, running the debug version will output:
Setting t to null
Finalizer
note that here the finalizer runs as a result of the AD shutdown,
while the release version shows:
Finalizer
Setting t to null
which actually illustrates Nicholas point, or am I missing your
point.
No, it doesn't illustrate Nick's point - it counters it. The only way
setting t to null could prolong the object's lifetime would be if the
GC kept the object alive due to the assignment. As the finalizer is
being run *before* the assignment, that shows the GC realises that the
variable isn't going to be *read* again, even though it will be written
- so the variable isn't treated as a GC root.
The assignment to null certainly doesn't help, but it doesn't actually
hinder the GC either.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too