[Haskell-cafe] Are handles garbage-collected?
Simon Marlow
simonmar at microsoft.com
Mon Oct 25 09:14:28 EDT 2004
On 24 October 2004 20:51, Sven Panne wrote:
> IMHO it would be best to use explicit bracketing where possible, and
> hope for the RTS/GC to try its best when one runs out of a given
> resource. Admittedly the current Haskell implementations could be
> improved a little bit in the last respect.
Indeed, GHC could/should try to free up file descriptors when they run
out. It's a bit tricky though.
At the moment performGC doesn't actually run any finalizers. It
schedules a thread to run the finalizers, and you hope the thread runs
soon. So if you're running performGC for the purposes of finalization,
then almost certainly (performGC >> yield) is better. I've been
wondering whether having a more synchronous kind of finalizer would be a
good thing.
Nevertheless, I agree with the general sentiment on this thread that
file descriptors shouldn't be treated as a resource in the same way as
memory.
Cheers,
Simon
More information about the Haskell-Cafe
mailing list