Destructor nonsense on dlang.org

Mehrdad wfunction at hotmail.com
Fri May 25 08:49:56 PDT 2012


On Friday, 25 May 2012 at 14:35:58 UTC, Andrei Alexandrescu wrote:
> What happens in C# if an object A that has a field referring to 
> object B, and the object B has in turn a field referring to 
> object A? That is:
> What happens then? Will the GC nullify references to destroyed 
> objects, or will it put them in a zombie state?

Depends.

If it's a _manual_ disposal, everything is fine -- neither is
GC'd yet.

If it's an _automatic_ disposal (a.k.a. garbage collection), then
the cross references must not be used. I believe their contents
are either undefined or null, but in either case, you don't worry
about disposing them because the objects will take care of
themselves.


More information about the Digitalmars-d mailing list