when is the object destuctor called?

Ben Hinkle bhinkle at mathworks.com
Mon May 22 10:13:02 PDT 2006


> static this()
> {
>    foreach(Texture t; textures)
>        delete t;
> }
>
> All instances are deleted.
>
> This works well, and if the GC behavior is ever changed, this mechanism 
> will still work.

Except there's the large downside that the textures will *only* be freed at 
program exit. If you delete one of the objects by hand you'll try to delete 
it again at exit which is an error and the GC will never collect the object 
since it is always referenced by the static array. 





More information about the Digitalmars-d mailing list