GC object finalization not guaranteed
Christopher Wright
dhasenan at gmail.com
Sat Apr 18 19:06:52 PDT 2009
Walter Bright wrote:
> Leandro Lucarella wrote:
>> You missed the point. I'm not talking about freeing the memory. I'm
>> talking about finalizers. A finalizer could send a "bye" packet throgh
>> the
>> net. That can't be handled by the OS.
>
> That shouldn't be handled by a finalizer. A "bye" packet can be handled
> by a static destructor.
That requires more work -- you have to keep track of a bunch of
instances that are active, and then the static destructor goes through
all of them and nukes them each in turn. It isn't a whole lot of work, I
admit. But it is -- or at least, it is perceived as -- an idiom to make
up for an inadequacy of the garbage collector.
> Finalizers are fairly useless for gc. But they are a lot more useful as
> RAII destructors.
Then maybe finalizers should be divorced entirely from garbage collection.
More information about the Digitalmars-d
mailing list