
13 Jan
2019
13 Jan
'19
5:58 p.m.
Hi, Ptr has no finalizer: you have to explicitly free the attached memory if necessary. You can use ForeignPtr to associate finalizers to a pointer: finalizers are functions that are called when the ForeignPtr object is to be collected by the GC. GHC can't track if the pointer is still stored/used by the C lib though. Hope that helps, Sylvain On 12/01/2019 07:16, Magicloud Magiclouds wrote:
Hi,
Say I have some data, and `poke` into a Ptr. Then I pass the Ptr to some function in C lib. The C lib stores the Ptr somewhere to use later.
My question is, how does GHC handle the finalizing of the Ptr? Does it track the "used by foreign lib"?