[Haskell-cafe] help optimizing memory usage for a program

Bulat Ziganshin bulat.ziganshin at gmail.com
Mon Mar 2 16:32:53 EST 2009

Hello Austin,

Monday, March 2, 2009, 11:51:52 PM, you wrote:

>> let's calculate. if at GC moment your program has allocated 100 mb of
>> memory and only 50 mb was not a garbage, then memory usage will be 150
>> mb

> ? A copying collector allocates a piece of memory (say 10mb) which is
> used as the heap, and only one *half* of it ever has data in it. When

if you interested, i suggest you to run any memory-eater with +RTS -S
switch. it's somewhat hard to decrypt, but finally you will see what i

let's imagine that you have 10mb heap at moment of GC, and only 7 mb
are live. when doing GC, ghc copies live data into new blocks
allocated from the OS. so after GC program will occupy 10+7 mb. ghc
can't return memory back to the OS, so it uses those 10 mb to fulfill
further memory requests. as a result, next GC will occur when 17 mb
will be consumed

you have described some fixed-pool scheme which is probably simplified
description of idea don't taking into account dynamic poll growth

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list