Manual memory management in D2
bearophile
bearophileHUGS at lycos.com
Sun Jul 11 11:29:40 PDT 2010
Simen kjaeraas:
> Petr:
>> What would happen if i skipped clear()?
>
> Then your destructors wouldn't get called. GC.free takes a humble void
> pointer, which knows little of destructors and other such fancy things.
>
> If you feel unsure you will remember, feel free to use this function:
>
> void destroy( T )( T obj ) if ( is( T == class ) ) {
> clear( obj );
> GC.free( obj );
> }
That can be a good thing to add to Phobos2 or the core. An overloaded version with the same name for nonclasses can be added.
Bye,
bearophile
More information about the Digitalmars-d
mailing list