[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-cafe
Subject:    Re: [Haskell-cafe] FFI and modifying haskell memory
From:       Sven Panne <Sven.Panne () aedion ! de>
Date:       2005-10-29 15:35:10
Message-ID: 200510291735.10907.Sven.Panne () aedion ! de
[Download RAW message or body]

Am Samstag, 29. Oktober 2005 14:27 schrieb Joel Reymont:
> So both with and allocaBytes allocate bytes on the stack then, correct?

It depends on what you mean by "stack". :-) From a conceptual point of view, 
both pass a pointer to a temporary memory region to a given action *which is 
only valid during the execution of the action*, so it would be incorrect to 
if the pointer somehow "escapes" the action.

How this temporary memory is actually allocated depends on the implementation: 
Hugs and NHC use malloc/free, ensuring that free is even called in case of an 
exception, so that there will be no space leaks. GHC does something more 
efficient by allocating the memory from the normal Haskell runtime heap, but 
ensuring that the memory is never moved by garbage collection. This is called 
"pinned memory" sometimes, see e.g. Java's JNI.

Cheers,
   S.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic