GC does not delete subclass
Gide Nwawudu
gide at btinternet.com
Tue Dec 18 15:56:16 PST 2007
On Tue, 18 Dec 2007 11:45:49 -0800, Sean Kelly <sean at f4.ca> wrote:
>Matthias Thurau wrote:
>> "If the objects are no longer referenced, the GC will destroy those also."
>>
>> Thats exact the case: In my example the GC isn t destroying that unreferenced member.
>
>Technically, it is. It's just not destroying it in the collection
>immediately following the object's allocation, which isn't guaranteed
>anyway. As I said previously, it's likely that a register still holds
>the address of this object when the allocation is triggered, because
>basically nothing happens between the object's construction and the
>collection. In a real application, such things are unlikely occur.
>
>
> ~this() { writefln("Destructor %d", myNumber); }
To help the GC, is Java-like null assignment necessary? The following
line helps std.gc.fullCollect() to destroy My2Class members.
~this() { writefln("Destructor %d", myNumber); member = null; }
Gide
More information about the Digitalmars-d
mailing list