From: Michael Ekstrand <michael@elehack.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Bigarray
Date: Thu, 14 Apr 2011 08:57:50 -0500 [thread overview]
Message-ID: <4DA6FD5E.6060705@elehack.net> (raw)
In-Reply-To: <4DA6AE7E.9030707@altair.com>
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
prev parent reply other threads:[~2011-04-14 13:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-14 8:21 Fady Nassif
2011-04-14 13:57 ` Michael Ekstrand [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DA6FD5E.6060705@elehack.net \
--to=michael@elehack.net \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox