[Haskell-cafe] Re: Are handles garbage-collected?
simons at cryp.to
Sun Oct 24 08:16:50 EDT 2004
Tomasz Zielonka writes:
> AFAIK, Handles have finalisers which close them, but I
> don't know if GHC triggers garbage collection when file
> descriptors run out. If not, you will have problems if
> you manage to run out of fds between GCs.
Thank you for answering.
Now there is only one problem: Assuming I could _not_ use
'bracket', 'withFile', 'finally' or any of the other usual
scope-guarding techniques, what would I do? (The handle has
to be passed up to the outside of the scope in which it was
If I stored the handle in an 'MVar' and attached an
MVar-finalizer to that, would that work better? Would the
MVar's finalizer be run any sooner than the one attached to
the handle anyway?
Or can I explicitly trigger garbage collection somehow? Say,
in case I receive an exception telling me that file
descriptors are running out? Which exception would I even
get in this case?
More information about the Haskell-Cafe