Hi,

On 10/25/06, Hendrik Tews <H.Tews@cs.ru.nl> wrote:
>From the comments of Damien Doligez in a related thread in
http://caml.inria.fr/pub/ml-archives/caml-list/2004/07/84cd291931627c13faf56a259026885c.en.html
I got the impression that there is extra punishment for
caml_local_roots. Should the situation improve if I organize the
350.000 ocaml node pointers on the ocaml side via one local root
(asumming this information is needed not so often)?

This is a known problem: the OCaml-runtime calls this function (caml_oldify_local_roots) at each minor collection.  The function iterates over all local roots, and since minor collections happen quite often, this naturally leads to excessive CPU-usage - even if hardly anything else is going on.

To work around this problem you should store pointers to the C++-objects on the C++-side, and e.g. associate them with finalized OCaml-values, or handles which allow you to explicitly deallocate the objects.

It would be great if the GC could be improved in situations where there are many local roots.  This is a pretty common problem when interfacing non-trivial third party libraries, and the clumsy workarounds require writing somewhat error-prone code.

Best regards,
Markus

--
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com