[Haskell-cafe] Are handles garbage-collected?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Sun Oct 24 15:47:43 EDT 2004


"Conal Elliott" <conal at conal.net> writes:

> I'm puzzled why explicit bracketing is seen as an acceptable solution.
> It seems to me that bracketing has the same drawbacks as explicit memory
> management, namely that it sometimes retains the resource (e.g., memory
> or file descriptor) longer than necessary (resource leak) and sometimes
> not long enough (potentially disastrous programmer error).

If used correctly, it will retain it about the right amount of time,
while with garbage collection it's *impossible* to ensure that it will
not be retained too long. Most GC schemes don't guarantee promptness
of collection.

It doesn't matter for pure memory, because GC will be performed as
soon as enough memory has been allocated, but it matters for other
resources, except for programs which don't open many files at all.

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


More information about the Haskell-Cafe mailing list