GC and dtors ~ a different approach?

Sean Kelly sean at f4.ca
Thu Apr 13 09:52:31 PDT 2006


Bruno Medeiros wrote:
> Regan Heath wrote:
>> On Mon, 10 Apr 2006 13:33:56 +0100, Bruno Medeiros 
>> <brunodomedeirosATgmail at SPAM.com> wrote:
>>> All of those pros you mention are valid. But you'd have one serious con:
>>> * Any class which required cleanup would have to be manually memory 
>>> managed.
>>
>> Not memory managed, surely.. the memory will still be collected by the 
>> GC, all that changes is that the dtor is not invoked when that 
>> happens.. or at least that is how I understood Kris's proposal.
> 
> Kris clearly mentioned that a class with a dtor (i.e. a class needing 
> cleanup) being collected by the GC would be an abnormal situation. 
> (which could, or not, be detected by the runtime.)

The version of Ares released yesterday has code in place to do this. 
For now, you'll have to alter the finalizer if you wanted to do 
something special (dmdrt/memory.d:cr_finalize), but eventually it it 
will probably call an onFinalizeError function in the standard library 
that can be hooked in a similar manner to onAssertError.  The error will 
be signaled when the GC collects an object that has a dtor.  Default 
behavior will likely be to do ignore it and move on.


Sean



More information about the Digitalmars-d mailing list