Browse thread
Disabling the OCaml garbage collector
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Thomas Fischbacher <tf@f...> |
| Subject: | Re: [Caml-list] Disabling the OCaml garbage collector |
Raj, > The issue for me is that I need to be able to modify mutable objects in > OCaml (eg. array-modification in-place) from both OCaml and C/Python. > However, the OCaml GC moves things around while the execution is in > C/Python and this crashes my program. You strongly should consider malloc()ing data and providing caml functions to read and write entries from a C array. In case the data chunk you want to modify from both caml and C holds non-integer ml values, things become a bit more complicated. Then, you have to register_global_root() these extra pointers into the ML heap. Unregistering of global roots then has to be done in the finalizer of the ML container value that retains a C pointer to malloc()d space. There, you free() this as well. Beware the dreaded global root reference loop though! -- best regards, Thomas Fischbacher tf@functionality.de