Static Constructors

Saaa empty at
Sat Oct 4 08:49:54 PDT 2008

Thanks, from this I'd rather delete them manually :)

> The GC deletes an object (usually, but sometimes it doesn't do it because 
> it's not a precise GC) when there are no references to/from it.
> So if you keep it just inside an array, and it has no inbound references, 
> and you remove it somehow (for example overwriting it with the last item 
> of the array and then reducing the length of the array by 1), the GC loses 
> the only reference to that objects, and deallocates it.
> Note the same thing happens in most languages/systems that have a GC.
> If your object manages some other resources beside its memory, for example 
> an open file, you have to close it inside the destructor of your object. 
> If the not precise GC keeps a spurious (wrong) reference to your object 
> (because somewhere an int value looks like a pointer to the object memory 
> block), then you are in troubles...
> Bye,
> bearophile 

More information about the Digitalmars-d-learn mailing list