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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 83429BC6B for ; Tue, 27 Nov 2007 17:41:47 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKbXS0c+BBBmdGdsb2JhbACBW41jAQoEBg8YgRA X-IronPort-AV: E=Sophos;i="4.23,220,1194217200"; d="scan'208";a="4983958" Received: from smtp-102-tuesday.nerim.net (HELO kraid.nerim.net) ([62.4.16.102]) by mail1-smtp-roc.national.inria.fr with ESMTP; 27 Nov 2007 17:41:47 +0100 Received: from hector.lesours (ours.starynkevitch.net [213.41.244.95]) by kraid.nerim.net (Postfix) with ESMTP id 74913CF14B; Tue, 27 Nov 2007 17:41:46 +0100 (CET) Received: from [192.168.0.1] (glinka.lesours [192.168.0.1]) by hector.lesours (Postfix) with ESMTP id DF90920F1E5; Tue, 27 Nov 2007 17:39:40 +0100 (CET) Message-ID: <474C48C5.708@starynkevitch.net> Date: Tue, 27 Nov 2007 17:41:41 +0100 From: Basile STARYNKEVITCH User-Agent: Mozilla-Thunderbird 2.0.0.6 (X11/20071008) MIME-Version: 1.0 To: Raj Bandyopadhyay Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Disabling the OCaml garbage collector References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; basile:01 basile:01 ocaml:01 ocaml:01 allocates:01 afaik:01 camlparam:01 byterun:01 faiencerie:01 92340:01 reine:01 garbage:01 garbage:01 wrote:01 unix:01 Raj Bandyopadhyay wrote: > Dear all > > I am writing a foreign function interface between OCaml and another > language (Python) which works via C. Since I have some memory issues > currently, I would like to be able to disable the OCaml Garbage > collector before jumping into C/Python, and re-enable it when I return > to OCaml. I am not convinced it is possible or makes sense. More precisely, your foreign -coded in C, called by Ocaml code- function probably allocates some result, and this allocation can trigger the Ocaml garbage collector In addition, AFAIK, the Ocaml minor garbage collector is only running when called, either implicitly from some allocation routines, or explicitly. So if you don't allocate things either directly or indirectly (e.g. by calling some callback coded in Ocaml) the Ocaml GC is not running. > > I am using the OCaml/C interface and the macros that it provides to > manage values (CAMLlocal and CAMLparam), but I would like to be able to > disable the GC entirely for short periods. You definitely may need to hack the C code inside byterun/minor_gc.c (for example), but I don't understand what you want exactly. However, I do know that mixing GCs, like Ocaml & Python, is a nightmare. Did you consider having two separate Unix processes, one for the Ocaml code and one for the Python code, and having them communicate thru standard stuff like pipes, memory mapped files, ... -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mines, sont seulement les miennes} ***