Jules Bean wrote:
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'.

Deadlocked threads blocked on MVars instead get the BlockedOnDeadMVar exception. Perhaps those two exceptions should be merged.

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

Reply via email to