From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id B3CF77EE20 for ; Sat, 17 Nov 2012 19:29:22 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.83,270,1352070000"; d="scan'208";a="162848042" Received: from 4be54-7-78-230-69-17.fbx.proxad.net (HELO [192.168.0.23]) ([78.230.69.17]) by mail4-relais-sop.national.inria.fr with ESMTP/TLS/AES128-SHA; 17 Nov 2012 19:29:14 +0100 From: Samuel Hornus Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Sat, 17 Nov 2012 19:29:13 +0100 Message-Id: <70435661-3754-4815-9EEF-B52F33D29B5F@inria.fr> To: O Caml Mime-Version: 1.0 (Apple Message framework v1283) X-Mailer: Apple Mail (2.1283) Subject: [Caml-list] Segfault in C++ stub with many 'new' allocations Dear all, I have two questions. 1/ I'm writing a stub to the C++ ANN library [1] to find geometric neighbor= ing 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 suffic= iently from the C-style malloc, that bad interactions with OCaml heap happe= n ? (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 [floa= t 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/=