From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p3EDvw47023437 for ; Thu, 14 Apr 2011 15:57:58 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkYHAM78pk1APrys/2dsb2JhbACYOY09d8IXhW4EhVqMCA X-IronPort-AV: E=Sophos;i="4.64,211,1301868000"; d="scan'208";a="96948237" Received: from elehack.net ([64.62.188.172]) by mail2-smtp-roc.national.inria.fr with ESMTP; 14 Apr 2011 15:57:53 +0200 Received: from [128.101.33.159] (cs-wlc-159.cs.umn.edu [128.101.33.159]) by elehack.net (Postfix) with ESMTPSA id D9541EF288 for ; Thu, 14 Apr 2011 08:58:32 -0500 (CDT) Message-ID: <4DA6FD5E.6060705@elehack.net> Date: Thu, 14 Apr 2011 08:57:50 -0500 From: Michael Ekstrand User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: caml-list@inria.fr References: <4DA6AE7E.9030707@altair.com> In-Reply-To: <4DA6AE7E.9030707@altair.com> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Bigarray On 04/14/2011 03:21 AM, Fady Nassif wrote: > When we create a BigArray from C is it created in the C heap or in the > Caml Heap? And if we create it in Caml what happen?. > Since there is no data copying at all, I have some confusion about that. The bigarray's contents are created in the C heap in both cases. If you create a new bigarray from OCaml, the bigarray module uses malloc() to allocate the array's storage. When you create one from C, you allocate the memory yourself (typically using malloc()) and then wrap in in a bigarray object. If you used malloc() to allocate the memory and want OCaml to take responsibility for freeing it when the bigarray object is garbage collected, you can specify BIGARRAY_MANAGED in the flags parameter to alloc_bigarray_dims. This (undocumented) flag is used by the internal bigarray code when it creates a new bigarray with malloc. Otherwise, you are responsible for somehow freeing the bigarray storage at the appropriate time. - Michael