From: Markus Mottl <mottl@miss.wu-wien.ac.at>
Message-Id: <199908262009.WAA29246@miss.wu-wien.ac.at>
Subject: Re: GC with finalisation?
To: skaller@maxtal.com.au (John Skaller)
Date: Thu, 26 Aug 1999 22:09:32 +0100 (MET DST)
In-Reply-To: <3.0.6.32.19990824133643.009a89a0@mail.triode.net.au> from "John Skaller" at Aug 24, 99 01:36:43 pm
> I seem to have several choices.
>
> 1) implement reference counting for finalisation
>
> * disadvantage: same problem as CPython: doesn't resolve
> circular references properly
>
> * disadvantage: overhead and coding complexity
>
> * advantage: synchronous finalisation
The main problem with reference counting is speed. It is possible to
resolve circular references in linear time, but the constant overhead
and the associated memory requirements are simply too large.
Anyway, there is a nice fortune cookie pointing out potential problems
with recursive datastructures when doing reference counting:
One day a student came to Moon and said, "I understand how to make
a better garbage collector. We must keep a reference count of the
pointers to each cons."
Moon patiently told the student the following story -- "One day a
student came to Moon and said, "I understand how to make a better
garbage collector..."
[snip GC approaches]
I would leave all the work to the OCaml-GC: use module "Weak" to register
values (eg.: objects) to be finalized. Then check these arrays from
time to time and call appropriate finalization functions for objects
that have been reclaimed.
Regards,
Markus
-- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:24 MET