[Haskell-cafe] Are handles garbage-collected?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Mon Oct 25 15:42:16 EDT 2004

Remi Turk <rturk at science.uva.nl> writes:

> Hm, I'm not sure about the "should". Garbage collection is meant
> for memory, and anything making that less clear makes people
> more likely to depend on incorrect assumptions.
> And redefining GC to be a collection of _all_ garbage, instead of
> just memory doesn't sound so fantastic either.

I would not be surprised if relying on GC to close open files would
be generally considered kosher in a few years - in cases when it has
little visible effects outside, i.e. excluding network connections,
but including reading configuration files.

All which is needed is that the OS doesn't run out of system-wide
resources when only a given process opens many files; and that the
language implementation can actually force a garbage collection and
run finalizers of file objects immediately in the rare case when the
limit of per-process descriptors is reached.

Well, this has some impact on mixing languages, because when a module
implemented in one language runs out of file descriptors, it should
cause a program-wide GC of all runtimes. Maybe this style would apply
only to environments like .NET.

   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/

More information about the Haskell-Cafe mailing list