[Haskell-cafe] Re: FPS: Finalizers not running (was Memory usage outside of the Haskell heap)

Donald Bruce Stewart dons at cse.unsw.edu.au
Sun Nov 6 18:57:36 EST 2005


joelr1:
> David,
> 
> I followed your suggestion and I think the finalizers for FPS are not  
> running.

Hmm. Is this on Windows only though? Or also on unix?

> Please take a look at http://wagerlabs.com/Bar.hs to see what I mean.  
> I had to modify the FPS export list to expose the constructor but  
> that's the only change I made.

Should be exported already:

    module Data.FastPackedString (

            -- * The @FastString@ type
            FastString(..), -

Maybe you're running an old version?

-- Don


> The other useful tidbits are:
> 
> -- (internal) GC wrapper of mallocForeignPtrArray
> mallocForeignPtr :: Int -> IO (ForeignPtr Word8)
> mallocForeignPtr l = when (l > 1000000) performGC >>  
> mallocForeignPtrArray l
> 
> and
> 
> createPS :: Int -> (Ptr Word8 -> IO ()) -> FastString
> createPS l write_ptr = unsafePerformIO $ do
>     fp <- mallocForeignPtr l
>     withForeignPtr fp $ \p -> write_ptr p
>     return $ PS fp 0 l
> 
> I replaced mallocForeignPtr with a call to mallocForeignBytes but  
> that did not make a difference, the finalizers still don't run.
> 
> 	Joel
> 
> On Nov 5, 2005, at 4:57 PM, David Roundy wrote:
> 
> >You can attach a print message to the finalizer and also print a  
> >message
> >out when creating the string.  I've found this to be helpful at times.
> 
> --
> http://wagerlabs.com/
> 
> 
> 
> 


More information about the Haskell-Cafe mailing list