[Haskell-cafe] Re: [Haskell] Blocked STM & GC question

Jules Bean jules at jellybean.co.uk
Tue Sep 18 11:25:57 EDT 2007

Simon Marlow wrote:
> Ashley Yakeley wrote:
>> If I have a thread that's blocked on an STM retry or TChan read, and 
>> none of its TVars are referenced elsewhere, will it get stopped and 
>> garbage-collected?
>> I have in mind a pump thread that eternally reads off a TChan and 
>> pushes the result to some function. If the TChan is forgotten 
>> elsewhere, will the permanently blocked thread still sit around using 
>> up some small amount of memory, or will it be reaped by the garbage 
>> collector?
> In this case, your thread should receive the BlockedIndefinitely exception:
> http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#v%3ABlockedIndefinitely 
> If the system is idle for a certain amount of time (default 0.3s, change 
> it with the +RTS -I option) a full GC is triggered, which will detect 
> any threads that are blocked on unreachable objects, and arrange to send 
> them the BlockedIndefinitely exception.

Including MVars? Your quoted text suggests 'Yes' but the docs you link 
to suggest 'No'.


More information about the Haskell-Cafe mailing list