Ticket #7300 (new feature request)
Allow CAFs kept reachable by FFI to be forcibly made unreachable for GC
| Reported by: | absence | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | 7.8.1 |
| Component: | Compiler (FFI) | Version: | 7.4.1 |
| Keywords: | unsafe caf gc | Cc: | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Runtime performance bug | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
CAFs used by a foreign exported function are kept reachable the entire session because GHC can't know when the function will be called from C. If such a CAF is an evolving expression, like an FRP network, a space leak occurs because (I'm guessing) the thunks that build up during iteration go all the way back to the initial CAF, and the GC can't start collecting because it considers the CAF reachable. According to JaffaCake? on the #haskell IRC channel, the runtime is capable of sovling this problem, it just needs a function that tells it to consider the specific CAF unreachable. It is then the responsibility of the user to not call the foreign exported function after the CAF is forced unreachable.
