Ticket #7300 (new feature request)
Allow CAFs kept reachable by FFI to be forcibly made unreachable for GC
|Reported by:||absence||Owned by:|
|Keywords:||unsafe caf gc||Cc:|
|Type of failure:||Runtime performance bug||Difficulty:||Unknown|
|Test Case:||Blocked By:|
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.