[Ecls-list] Finalizer, weak pointer, weak hashes etc.

Juan Jose Garcia-Ripoll jjgarcia at users.sourceforge.net
Fri Apr 25 17:35:17 UTC 2008


On Thu, Apr 24, 2008 at 9:32 PM, Marco Gidde <marco.gidde at tiscali.de> wrote:
>  ... the user can easily turn of the internal object finalization
>  (ie. closing streams) with

Yes, that is a feature, not a big issue. You should set it to T if you
want the default finalizing code. But perhaps this semantics is not
very clear.

>  Weak pointers on the other hand seem to be quite simple: define a new
>  type with a pointer to cl_object, allocate this cell with malloc_atomic
>  and let GC_general_register_disappearing_link nullify it if appropriate.
>  With these building blocks implementing weak hash tables is still some
>  amount of work, but at least doable.

My understanding is that this is not efficient and that disappearing
links should be avoided if possible. I got this feedback from the GC
mailing list long ago. Now I am not sure what they meant, as having a
look at the garbage collector's code, they are implemented just like
finalization.

However, the real problem is that for scalable weak hashes it is not
enough to have weak pointers. This is described here:
http://www.haible.de/bruno/papers/cs/weak/WeakDatastructures-writeup.html
and here http://www.haible.de/bruno/papers/cs/weak/WeakDatastructures-presentation.pdf

Perhaps the simplest solution is, since we do not have control over
the "sweep" phase in the collector, to go for finalization. One could
add an "internal" finalization phase as you describe, storing objects
with weak pointer references in a hash table and updating this table
and clearing the associated pointers and conses when the object is
finalized.

Juanjo

-- 
Facultad de Fisicas, Universidad Complutense,
Ciudad Universitaria s/n Madrid 28040 (Spain)
http://juanjose.garciaripoll.googlepages.com




More information about the ecl-devel mailing list