[Haskell-cafe] ForeignPtr and Garbage Collection
matt at mattcox.ca
Tue Jul 30 20:16:12 CEST 2013
The pointer held in a ForeignPtr is not managed at all by the GC. The
ForeignPtr itself is a GC'd object and runs a finalizer (a function
receiving a pointer) with the value it holds when it is destroyed.
For example, if you allocate a C resource in one foreign call and then
store its value in a foreign pointer, that externally allocated memory it
points to is outside the management of the GC.
On Tue, Jul 30, 2013 at 9:50 AM, satvik chauhan <mystic.satvik at gmail.com>wrote:
> Hi Cafe,
> Is it guaranteed that the value of `ForeignPtr` will not be changed (for
> example due to compaction etc) by haskell garbage collector until it goes
> out of scope and finalizer is run.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe