[Haskell] memory management

Sigbjorn Finne sigbjorn.finne at gmail.com
Tue Aug 4 10:11:09 EDT 2009


Hi,

staying in the realm of the explicit and pragmatic, various libraries
in Haskell do provide safe&explicit region/alloca/stack allocation 
actions, e.g.,

  Foreign.Marshal.Alloc.allocaBytes :: Int -> (Ptr a -> IO b) -> IO b

with the promise that the pointer doesn't escape here (you could constrain
this using the type system, if you so wish..) I don't know if the GHC 
RTS still(?)
provides hooks for allocating "alloca" objects specially.

There's been some work on monadic regions too; worth looking at.

hth
--sigbjorn

On 8/4/2009 15:49, Simon Marlow wrote:
> On 04/08/2009 13:33, Sam Martin wrote:
>>> Sounds like region inference to me.
>>> (https://secure.wikimedia.org/wikipedia/en/wiki/Region_inference)
>>
>> Thanks, yes, that's exactly what I had in mind.
>>
>> Is anything like this is done in GHC?
>
> Not at the moment, no.
>
> Bear in mind that with generational GC, allocating memory that quickly 
> becomes garbage is quite cheap.
>
> Cheers,
>     Simon
>




More information about the Haskell mailing list