Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
caml_oldify_local_roots takes 50% of the total runtime
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-10-26 (14:54)
From: Markus Mottl <markus.mottl@g...>
Subject: Re: [Caml-list] caml_oldify_local_roots takes 50% of the total runtime
On 10/26/06, Hendrik Tews <> wrote:
> I don't quite understand: I only have pointers from C++ to ocaml.
> Once constructed the ocaml objects are completely independent
> from the C++ ones.

Ok, I thought they were entangled, i.e. there were pointers in both
directions.  But you will still need to avoid storing OCaml-values in

If you want to prevent them from being reclaimed as long as the C++-objects
still refer to them, you'll have to store them in e.g. an OCaml-hashtable
using e.g. integer keys as handles.  Then you can store the key in the
C++-object as an ordinary C++-value (i.e. no registering with the GC).  If
you need the OCaml-value on the C++-side, you just convert the handle to an
OCaml-value, and execute a callback to look up the value associated with the
handle in the hashtable.  Btw., if you use an OCaml-int as handle you can
store the "value" directly, because ints need not be registered with the GC


Markus Mottl