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 OAA10492; Sat, 3 Jan 2004 14:47:40 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 OAA10373 for ; Sat, 3 Jan 2004 14:47:39 +0100 (MET) Received: from mallaury.noc.nerim.net (smtp-106-saturday.noc.nerim.net [62.4.17.106]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id i03Dlcb24297 for ; Sat, 3 Jan 2004 14:47:38 +0100 (MET) Received: from inria.fr (planar.net0.nerim.net [213.41.168.102]) by mallaury.noc.nerim.net (Postfix) with ESMTP id CB44662D3B for ; Sat, 3 Jan 2004 14:47:36 +0100 (CET) Date: Sat, 3 Jan 2004 14:47:45 +0100 Subject: Re: [Caml-list] Modifying heap from custom finalizers? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v553) From: Damien Doligez To: caml-list@inria.fr Content-Transfer-Encoding: 7bit In-Reply-To: <878ykwni7c.fsf@naked.iki.fi> Message-Id: <69286889-3DF3-11D8-BEFF-00039310CAE8@inria.fr> X-Mailer: Apple Mail (2.553) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 finalizers:01 damien:01 damien:01 deed:99 finalizer:01 finalizers:01 invariants:01 compactor:01 bug:01 arrays:01 garbage:01 garbage:01 doligez:01 doligez:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Monday, December 29, 2003, at 09:25 AM, Nuutti Kotivuori wrote: > I am wonder how evil of a deed would I be doing to the garbage > collector by modifying the heap in the finalizer of a custom block. Ouch ! Tricky questions ahead ! > Apparently the finalizers are run during the sweep phase of the major > garbage collector. If I there change a value from the global table to > the unit value - I think that should work. > But, what about anything more? It's hard to tell what will break the invariants of the GC. My recommendation is that you do none of the following. > Assigning values? I guess it would work, as long as you're not making anything point to the minor heap (see below), and that you're not getting the values from weak arrays, and maybe some other strange corner cases. > Creating new values? No. There might be a way to make it work, but it'll be so hairy I don't even want to think about it. > Do I have to make sure the small heap stays empty? If you allocate in the minor heap, it can trigger a minor collection, which will reenter the major GC, maybe even call the compactor. Crash. > And if zeroing the value at sweep phase makes the values pointed by it > garbage collected only at the next collection, is there any I can > speed up the process? What makes you think there is no other pointer to these values ? And to the things pointed by these values ? > I could find no documentation what you can and what you can't do in > the finalizers for custom blocks. You should enter this in the bug tracking system as a feature wish. -- 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