Simon Marlow wrote:
On 13 June 2005 11:30, Gracjan Polak wrote:


My space problems continued... :)

Follow up :)


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.

Example:

list = ...
mapM_ writeOut list

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


This sould be:

writeOut :: Ptr Word8
writeOut dat = do
     hPutBuh handle dat 1024
     System.Mem.performGC
     Control.Concurrent.threadDelay 1000


My small experimets show, that gc is not triggered?!?! What are the conditions to trigger gc? As I read the docs, is some % of heap. Is mallocForeinPtrBytes counted into that %?

Anyway I ended up triggering GC by hand and giving it time to run finalizers. Frankly speaking this is nonsolution:(

Related question:

Documentation says:
 -Msize
[Default: unlimited] Set the maximum heap size to size bytes. The heap normally grows and shrinks according to the memory requirements of the program...

GHC 6.4 says:
Heap exhausted;
Current maximum heap size is 268435456 bytes (256 Mb);
use `+RTS -M<size>' to increase it.

What am I missing?

PS: I might be mistaken in any of above statements. I'll be thankful for any light... :)

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

Reply via email to