GC object finalization not guaranteed

Rainer Deyke rainerd at eldwood.com
Sat Apr 18 15:18:28 PDT 2009


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.

It can't be handled by the GC either, because:
  - This would require a high-level wrapper that knows about the "bye"
packet around a low-level socket that doesn't know.  By the time the
high-level wrapper is finalized, the low-level socket may already have
been collected.
  - It is bad form to wait for the next garbage-collection cycle before
cleanly terminating connections.

What you need is RAII, not garbage collection.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list