* [Caml-list] Bigarray
@ 2011-04-14 8:21 Fady Nassif
2011-04-14 13:57 ` Michael Ekstrand
0 siblings, 1 reply; 2+ messages in thread
From: Fady Nassif @ 2011-04-14 8:21 UTC (permalink / raw)
To: caml-list
Hello,
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.
Thanks
Fady
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Bigarray
2011-04-14 8:21 [Caml-list] Bigarray Fady Nassif
@ 2011-04-14 13:57 ` Michael Ekstrand
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ekstrand @ 2011-04-14 13:57 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-14 13:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-14 8:21 [Caml-list] Bigarray Fady Nassif
2011-04-14 13:57 ` Michael Ekstrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox