IORefs and garbage collection
simonmarhaskell at gmail.com
Thu Apr 20 03:47:05 EDT 2006
Tomasz Zielonka wrote:
> On Wed, Apr 19, 2006 at 01:56:25PM +0400, Bulat Ziganshin wrote:
>>generational GC (at least one used in GHC) is better suited for
>>"functional" (immutable) data. this conception by itself based on that
>>new allocated data can contain references to old ones but not vice
>>versa. minor GC algorithms scans only new data, if they don't contain
>>any references to some data cell (in new data), then all the heap
>>don't contain references to this cell and it can be freed. most of the
>>data in "normal" Haskell program are immutable so this works fine.
> But most of the data is also lazy, and laziness in GHC is implemented
> with mutation. I wonder how does GHC's GC handle thunk update.
Thunks are a special case, because they only mutate once. We have a
write barrier in the thunk update code. Not much has changed in this
regard since Sansom's original generational GC for GHC:
The GC has been replaced since then, and is now multi-generational
rather than being fixed at 2 generations, amongst other things.
More information about the Glasgow-haskell-users