GC object finalization not guaranteed

Leandro Lucarella llucax at gmail.com
Sat Apr 18 14:51:59 PDT 2009


Walter Bright, el 18 de abril a las 14:33 me escribiste:
> Leandro Lucarella wrote:
> >The current GC implementation don't call finalizers for data that's still
> >reference when the program *ended* (this is allowed by the specs, so it's
> >fine, the question is why it's allowed by the specs).
> 
> The why is because of speed. What's the point of running a gc pause on
> program exit? The OS recovers all the memory anyway.

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.

And I'm not talking about doing a collection at program exit either. I'm
talking about just calling the finalizers.

What I say is to do this (in some kind of pseudocode, which is actually
valid code in my example naive GC implementation =):

void gc_term()
{
	foreach (cell; this.live_list)
		rt_finalize(cell.ptr);
}

No collection, no free.

What do you think about that? And about finalizers being completely
useless if the excecution is not guarateed? I would really like to know
(Sean's opinion would be appreciated too, being in charge of druntime).

Maybe this can be an improvement for D2 (I don't think you'll like to
change the specs for D1 =).

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
A veces quisiera ser un auto,
para chocar como choco siendo humano,
para romperme en mil pedazos.



More information about the Digitalmars-d mailing list