
Robert Dockins
This is exactly the guarantee you _don't_ have. The only guarantee you have is that it _won't_ be run if the Ptr _is_ being referenced.
From the GHC library documentation:
newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a) [...] The only guarantee is that the finaliser runs before the program terminates. So it seems, finalization *is* guaranteed, just not promptness of finalization.
My concern is that this approach is a little too non-deterministic. Because playing sound involves HW resources, [...]
If I understand correctly, the OP is dealing with library resources (mainly memory) while the library is managing the hardware ressources. Udo. __________________________________________________________ Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min. weltweit telefonieren! http://freephone.web.de/?mc=021201