Finalizers and FFI
Arjan van IJzendoorn
afie at cs.uu.nl
Thu Jun 10 15:53:32 EDT 2004
On 10-jun-04, at 17:33, Gracjan Polak wrote:
>
> foreign import stdcall "windows.h &UnmapViewOfFile"
> funptrUnmapViewOfFile :: FunPtr (Ptr a -> IO ())
>
[...]
> finview <- newForeignPtr funptrUnmapViewOfFile view
> return finview
>
> Strangely enough my finalizer run always this time, no need to say
> performGC or yield'ing at the end of main. But it crashes my program
> :(
That's why I stopped using the newForeignPtr from Foreign.ForeignPtr.
It also crashed. I wrote:
foreign import ccall "..." finaliserCreator :: IO (FunPtr (Ptr a -> IO
()))
and then
finaliser <- finaliserCreator
That's why I wrote: "I don't know how to make a FunPtr". I thought I
knew, but then it crashed.
> Any ideas where to go now?
Sorry. As I said before, the Concurrent ForeignPtr works for me. On
Windows. But it may be so that the finalisers are not called at the end
of the program but only at GC time. For my application this is no
problem.
Arjan
More information about the Glasgow-haskell-users
mailing list