[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
> I followed your suggestion and I think the finalizers for FPS are not
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
Maybe you're running an old version?
> The other useful tidbits are:
> -- (internal) GC wrapper of mallocForeignPtrArray
> mallocForeignPtr :: Int -> IO (ForeignPtr Word8)
> mallocForeignPtr l = when (l > 1000000) performGC >>
> mallocForeignPtrArray l
> 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.
> On Nov 5, 2005, at 4:57 PM, David Roundy wrote:
> >You can attach a print message to the finalizer and also print a
> >out when creating the string. I've found this to be helpful at times.
More information about the Haskell-Cafe