
Peter Verswyvelen wrote:
Yes, I was really surprised that this was the case. I while ago I did a little FRP experiment. I made a top level binding to a list of timer event occurrences. The list was generated on another thread. To my surprise, I did not have space leak, which is amazingly cool, but it felt odd :) Is it documented when GHC will garbage collect CAFs?
CAFs are garbage collected when they are unreachable by traversing the code that is reachable from the currently running program. In practice we don't actually traverse the code, instead we have these "static reference tables" that list the top-level closures referenced by each code block, and traverse those instead. Unfortunately we didn't get around to documenting the details of how this works... Cheers, Simon