[Haskell-cafe] heap lifetime question

Galchin, Vasili vigalchin at gmail.com
Thu Aug 7 02:38:56 EDT 2008


that is what I thought .. especially after just looking at the
implementation for alloca/allocaBytes. For me and others on thie group is
there documentation on the ghc run-time model and also the run-time library
architecture. Both would help/aid in reading the code and of course educate
more people?

Regards,

Vasili

On Thu, Aug 7, 2008 at 1:36 AM, Henning Thielemann <
lemming at henning-thielemann.de> wrote:

>
> On Thu, 7 Aug 2008, Bulat Ziganshin wrote:
>
> > Hello Vasili,
> >
> > Thursday, August 7, 2008, 9:33:32 AM, you wrote:
> >
> > oh, it was my mistake. alloca behavior is completely defined by it's
> > generic implementation:
> >
> > allocaBytes      :: Int -> (Ptr a -> IO b) -> IO b
> > allocaBytes size  = bracket (mallocBytes size) free
> >
> > although GHC implementation is much more efficient
>
> That is, it is not a good idea to use 'allocaBytes n return' in order to
> carry a pointer of an allocated piece of memory out of the inner action.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080807/ed3a3fea/attachment.htm


More information about the Haskell-Cafe mailing list