From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA05287 for caml-redistribution; Sat, 28 Aug 1999 19:25:27 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA12397 for ; Fri, 27 Aug 1999 07:23:39 +0200 (MET DST) Received: from iggy.triode.net.au (iggy.triode.net.au [203.63.235.1]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id HAA07197 for ; Fri, 27 Aug 1999 07:23:33 +0200 (MET DST) Received: from egret (pm1-5.triode.net.au [203.63.235.21]) by iggy.triode.net.au (8.9.3/8.8.8) with SMTP id PAA13463; Fri, 27 Aug 1999 15:15:36 +1000 Message-Id: <3.0.6.32.19990827151006.0099e930@mail.triode.net.au> X-Sender: skaller@mail.triode.net.au X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Fri, 27 Aug 1999 15:10:06 +1000 To: Markus Mottl From: John Skaller Subject: Re: GC with finalisation? Cc: caml-list@inria.fr (OCAML) In-Reply-To: <199908262009.WAA29246@miss.wu-wien.ac.at> References: <3.0.6.32.19990824133643.009a89a0@mail.triode.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: weis At 22:09 26/08/99 +0100, Markus Mottl wrote: >> I seem to have several choices. >> 1) implement reference counting for finalisation >The main problem with reference counting is speed. I was hoping to avoid it .. >It is possible to >resolve circular references in linear time, but the constant overhead >and the associated memory requirements are simply too large. I think this is less of a problem than actually writing the collector, and then changing all my code to use it. >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. That is an interesting idea -- but it won't work, because the destructor must be called _before_ the object is destroyed by the system. For example, one of my objects maintains the table of contents for a document, and when the object becomes unreachable, it is printed to a file as HTML. Obviously, the object still has to exist at this point, and retain all attributes. However, your idea of using weak arrays may be useful after all, if I can create a 'symbol' for the object, and put that into the weak array: the symbols contains lists of symbols, representing objects the object depends on. The collector will now collect symbols, and by checking the weak array I can execute destructors, and then release it for collection (by removing it from a corresponding 'strong' array). The problem is: it will be slower than reference counting, and not be entirely synchronous. The advantage is it will finalise unreachable objects with circular references. Also, reference counting can be added anyhow, to make non-circular finalisation synchronous. Hmm. Comments? ------------------------------------------------------- John Skaller email: skaller@maxtal.com.au http://www.maxtal.com.au/~skaller phone: 61-2-96600850 snail: 10/1 Toxteth Rd, Glebe NSW 2037, Australia