Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Basile STARYNKEVITCH <basile@starynkevitch.net>
To: Raj Bandyopadhyay <rajb@rice.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Disabling the OCaml garbage collector
Date: Tue, 27 Nov 2007 17:41:41 +0100	[thread overview]
Message-ID: <474C48C5.708@starynkevitch.net> (raw)
In-Reply-To: <ECF91B46-A0FC-46FD-BFAD-7BE07CEF1C85@rice.edu>

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: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***


  reply	other threads:[~2007-11-27 16:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-27 16:28 Raj Bandyopadhyay
2007-11-27 16:41 ` Basile STARYNKEVITCH [this message]
2007-11-28 18:05   ` [Caml-list] " Raj
2007-11-28 18:15     ` Alain Frisch
2007-11-28 18:31       ` Thomas Fischbacher
2007-11-28 19:30         ` Raj
2007-11-28 18:25     ` Thomas Fischbacher
2007-11-28 18:32     ` Xavier Leroy
2007-11-28 19:33       ` Raj
2007-11-28 20:00         ` Thomas Fischbacher
2007-12-04 20:14           ` Raj Bandyopadhyay
2007-12-05  4:07             ` Jon Harrop
2007-11-29  8:54     ` Frédéric van der Plancke
2007-11-27 17:05 ` [Caml-list] Python and Caml (was: Disabling the OCaml garbage collector) Thomas Fischbacher
2011-08-04 13:10   ` [Caml-list] Python and Caml Stéphane Glondu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=474C48C5.708@starynkevitch.net \
    --to=basile@starynkevitch.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=rajb@rice.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox