On 1/10/07, Malcolm Wallace <[EMAIL PROTECTED]> wrote:
"Samuel Bronson" <[EMAIL PROTECTED]> wrote:

> > Can I just leave it hanging and rely on the garbage collector to
> > close it in the fullness of time?
>
> Actually, hGetContents closes the handle when it gets an EOF.
>
> If it never does get EOF (because you never use all of the data), the
> garbage collector *might* close the handle, but I haven't heard of a
> garbage collector that was aware of the value of resources other than RAM

Actually, I'm pretty sure that most Haskell RTS implementations have a
finalizer attached to all file handles.  Once the file handle is no
longer reachable from the program graph (even if its data has not been
fully consumed), the GC will close the file (via the finalizer) before
reaping the memory associated with the handle.

Yeah, what I mean is that the garbage collector does not *look* for
unreachable filehandles to close, or get run when many filehandles
have been allocated. It only runs finalizers when it happens upon
things with finalizers, it doesn't have any idea what they are for.
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to