[Haskell-cafe] Garbage collection and finalizer thread priority

Gracjan Polak gracjan at acchsh.com
Mon Jun 13 06:29:56 EDT 2005


My space problems continued... :)

I have some ForeignPtr's, with finalizers (finalizerFree only). And I 
have lazyly produced list of those (yes, there is some unsafePerformIO 
magic behind, but I think I got this right). The problem is I get 
out-of-memory condition because elements get produced faster than those 
consumed are garbage collected.


list = ...
mapM_ writeOut list

writeOut :: Ptr Word8
writeOut dat = do
     hPutBuh handle dat 1024
     -- Control.Concurrent.threadDelay 1000

Uncommenting this line allows gc thread to run finalizers, memory gets 
freed, everything runs smoothly...

As far as I know finalizers are run in separate thread. How do I 
increase priority of this thread so it runs faster?


More information about the Haskell-Cafe mailing list