From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA22467; Thu, 1 Apr 2004 19:07:38 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA23321 for ; Thu, 1 Apr 2004 19:07:37 +0200 (MET DST) Received: from isis.lip6.fr (isis.lip6.fr [132.227.60.2]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i31H7aYM024751 for ; Thu, 1 Apr 2004 19:07:36 +0200 Received: from spi.lip6.fr (spi.lip6.fr [132.227.83.193]) by isis.lip6.fr (8.12.11/jtpda-5.4+victor) with ESMTP id i31H7aW1027777 for ; Thu, 1 Apr 2004 19:07:36 +0200 X-pt: isis.lip6.fr Received: from [132.227.83.219] (doligezportable.lip6.fr [132.227.83.219]) by spi.lip6.fr (8.11.6/jtpda-5.2) with ESMTP id i31HE3m17102 for ; Thu, 1 Apr 2004 19:14:03 +0200 Mime-Version: 1.0 (Apple Message framework v613) In-Reply-To: References: Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <1E3A29A6-83FF-11D8-BD34-00039310CAE8@inria.fr> Content-Transfer-Encoding: 7bit From: Damien Doligez Subject: Re: [Caml-list] Weak pointers and Gc.finalise Date: Thu, 1 Apr 2004 19:07:55 +0200 To: caml-list@inria.fr X-Mailer: Apple Mail (2.613) X-Scanned-By: isis.lip6.fr X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; damien:01 damien:01 caml-list:01 pointers:01 shivkumar:01 pointers:01 marshaling:01 bigarray:01 bigarray:01 inefficient:01 behaviour:01 doligez:01 doligez:01 marshal:01 marshal:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Keywords: X-UID: 19 On Apr 1, 2004, at 06:48, Shivkumar Chandrasekaran wrote: > I just noticed that if the only reference to a bigarray is in a Weak.t > array, and if there is a finalisation function set on the bigarray, > then that finalisation function is not necessarily called when the > entry in the Weak.t array is set to None. Rather it is potentially > called *much* later. That's right. Within a GC cycle, we first handle the weak pointers that have to be erased, then we handle the finalised values. > I am assuming that this is the right behaviour. We have to do it that way because there might be several weak pointers to the same value, and they have to be all erased before we call the finalisation function. > My question is, can I get the finalisation function to be called when > the weak pointer is being set to None? I guess it might be possible to attach functions to weak pointers, to be called when the weak pointer is erased, but that would be different from finalisation functions, and it would need a large amount of work to modify the GC. > (Side note: I am trying to avoid Marshaling the Bigarray unless it is > going to be garbage-collected. But if I cannot detect that, then I > have to always Marshal it whenever its entries change, which is very > inefficient.) I'm not sure I understand. The finalisation function is called when the value is about to be garbage-collected. Why can't you just marshal it at that point? -- Damien ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners