2) AFAIR there are functions like register_global_root which prevents GC from moving values. Best wishes, Kakadu On Sat, Nov 17, 2012 at 10:29 PM, Samuel Hornus wrote: > > Dear all, > > I have two questions. > > 1/ I'm writing a stub to the C++ ANN library [1] to find geometric > neighboring points in space. > The constructor of the main class in this library uses a lot of allocation > with the "new" C++ keyword. > For small input point sets (e.g. 2500 points), it all seems to work fine. > For larger ones (50 K points), the C++ constructor crashes. > My question is : is it possible that the C++ "new" allocator differs > sufficiently from the C-style malloc, that bad interactions with OCaml heap > happen ? > > (I'm passing the input points coordinates in a plain bigarray.) > > 2/ Regarding bigarray: before using them, I let the C++ constructor > access, and keep pointers inside regular OCaml [float array] or [float > array array]. It was working well (again, for small input point set), but > is that safe ? Or can the garbage collector eventually relocate the content > of a [float array] or of a [float array array] ? so that the pointer kept > in the C++ class would become dangling ? > > Thank you in advance, > Sam > > [1] Approximate Nearest Neighbors http://www.cs.umd.edu/~mount/ANN/ > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs