https://hackage.haskell.org/package/base-4.9.0.0/docs/Foreign-ForeignPtr.html https://hackage.haskell.org/package/base-4.9.0.0/docs/Foreign-ForeignPtr.html
Haskell - Where does GHC allocate foreign memory and how does the garbage collector treat it
De openkb
Sommaire |
Questions
Answers
malloc calls the C malloc(), so it allocates memory on the C heap which you have to free manually. (You can also do that from C with free() if you like.)
alloca and mallocForeignPtr allocate pinned byte arrays, which live on the Haskell pinned heap. The GC will free these automatically when they re no longer needed, but will never move them (since they re pinned) so you can pass their addresses to a C function.
newForeignPtr doesn t seem relevant to your question.
Source
License : cc by-sa 3.0
http://stackoverflow.com/questions/38349273/where-does-ghc-allocate-foreign-memory-and-how-does-the-garbage-collector-treat