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 RAA29305; Fri, 21 Mar 2003 17:35:13 +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 RAA29754 for ; Fri, 21 Mar 2003 17:35:11 +0100 (MET) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h2LGZ9X14357; Fri, 21 Mar 2003 17:35:10 +0100 (MET) Received: from kiefer.ai.univie.ac.at (markus@kiefer.ai.univie.ac.at [131.130.174.157]) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian-5) with ESMTP id h2LGZ8V7026461; Fri, 21 Mar 2003 17:35:08 +0100 Received: (from markus@localhost) by kiefer.ai.univie.ac.at (8.12.3/8.12.3/Debian-5) id h2LGZ8ZI010448; Fri, 21 Mar 2003 17:35:08 +0100 Date: Fri, 21 Mar 2003 17:35:08 +0100 From: Markus Mottl To: Damien Doligez Cc: OCAML Subject: Re: [Caml-list] GC and preventing data relocation Message-ID: <20030321163508.GA10107@kiefer.ai.univie.ac.at> Mail-Followup-To: Damien Doligez , OCAML References: <20030320151647.GA15121@fichte.ai.univie.ac.at> <4DE5D5EC-5BB8-11D7-856E-0003930FCE12@inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4DE5D5EC-5BB8-11D7-856E-0003930FCE12@inria.fr> User-Agent: Mutt/1.4i Organization: Austrian Research Institute for Artificial Intelligence X-Spam: no; 0.00; caml-list:01 damien:01 compactor:01 callback:01 c-interface:01 buffer:01 c-code:01 overwriting:01 dynamically:01 million:98 ocaml:01 doligez:01 raises:01 mottl:02 exception:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 21 Mar 2003, Damien Doligez wrote: > In the current implementation (and in the foreseeable future), if your > string is in the major heap, then only the compactor can move it. > You could try to disable the automatic compaction (by setting > max_overhead to 1 million) during the callback, restoring the > original setting when you get out of the callback. You'll have > to tell your users that they must not call Gc.compact nor change > max_overhead during the execution of the callback function. Well, I always get headaches when relying on users reading manuals ;-) > You will also have to correctly manage the case where the callback > function raises an exception... Of course! Luckily, the C-interface of OCaml is quite convenient and allows one to handle such cases without problems. > If the string is in the minor heap, you know it's a short string and > you can (for example) copy it into a buffer pre-allocated in the C heap. Unfortunately, this won't work, because the callback may again call the C-code, either overwriting the buffer or requiring me to write my own memory management. I don't think the latter is worthwhile so I'll just dynamically allocate buffers as required. Regards, Markus -- Markus Mottl markus@oefai.at Austrian Research Institute for Artificial Intelligence http://www.oefai.at/~markus ------------------- 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