On 07/02/2012, at 2:50 PM, Clark Gaebel wrote:

> I would be running the GC manually at key points to make sure it gets cleaned 
> up. Mainly, before any scene changes when basically everything gets thrown 
> out anyways.


>From the docs:

newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)Source
Turns a plain memory reference into a foreign pointer, and associates a 
finalizer with the reference. The finalizer will be executed after the last 
reference to the foreign object is dropped. There is no guarantee of 
promptness, however the finalizer will be executed before the program exits.


"No guarantee of promptness". Even if the GC knows your pointer is unreachable, 
it might choose not to call the finaliser. I think people have been bitten by 
this before.

Ben.


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to