Hi,
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