more on dotnet, gc, and memory management (part b)
the second example shows how you can resurrect an object while it is being finalized and also how you are able to use dispose to remove the need for finalization.
here is the code:
With Line Numbers and
Without Line Numbers
which produces the following output:
BEGIN:
Test4 (blarg) Constructor
Test4 (futz) Constructor
Start First Collection Point
Test4 Finalize [futz][2]
Test4 Finalize [blarg][1]
Test4 Resurrecting [blarg][1]
End First Collection Point
Test4 (blarg2) Constructor
Test4 Dispose [blarg][1]
Test4 (futz2) Constructor
Test4 Dispose [blarg2][1]
Test4 Dispose [futz2][0]
Start Second Collection Point
End Second Collection Point
END
the main things to notice:
- the resurrection and later death of the Test4(blarg) item
- the second collection point has no finalization methods in it
|