From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id AA867BC6B for ; Wed, 28 Nov 2007 19:17:58 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAGo/TUfU4368nmdsb2JhbACPPgEBAQEHBAYRGA X-IronPort-AV: E=Sophos;i="4.23,225,1194217200"; d="scan'208";a="19779390" Received: from moutng.kundenserver.de ([212.227.126.188]) by mail4-smtp-sop.national.inria.fr with ESMTP; 28 Nov 2007 19:17:58 +0100 Received: from [152.78.96.56] (babylon.cip.physik.uni-muenchen.de [141.84.136.30]) by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis) id 0MKwtQ-1IxRTj0WVv-000171; Wed, 28 Nov 2007 19:17:43 +0100 Message-ID: <474DB28A.8090403@functionality.de> Date: Wed, 28 Nov 2007 18:25:14 +0000 From: Thomas Fischbacher User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060607 Debian/1.7.12-1.2 X-Accept-Language: en MIME-Version: 1.0 To: Raj Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Disabling the OCaml garbage collector References: <474C48C5.708@starynkevitch.net> <474DADF7.5020204@rice.edu> In-Reply-To: <474DADF7.5020204@rice.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX1/4X59oVUOckBbki19KZaM1qlxM1SE+Rl2/vUe junVgA0X8wyMWo0kCGdRWk8um7JFlr8uHa8CPcmi4ZiUdlX1P0 V5GnZrGK2JBRo08+et9WQ== X-Spam: no; 0.00; ocaml:01 mutable:01 ocaml:01 malloc:01 pointers:01 finalizer:01 pointer:01 malloc:01 garbage:01 heap:01 caml-list:01 functions:01 data:02 data:02 caml:02 Raj, > The issue for me is that I need to be able to modify mutable objects in > OCaml (eg. array-modification in-place) from both OCaml and C/Python. > However, the OCaml GC moves things around while the execution is in > C/Python and this crashes my program. You strongly should consider malloc()ing data and providing caml functions to read and write entries from a C array. In case the data chunk you want to modify from both caml and C holds non-integer ml values, things become a bit more complicated. Then, you have to register_global_root() these extra pointers into the ML heap. Unregistering of global roots then has to be done in the finalizer of the ML container value that retains a C pointer to malloc()d space. There, you free() this as well. Beware the dreaded global root reference loop though! -- best regards, Thomas Fischbacher tf@functionality.de