[Haskell] Re: state of HaXml?

Samuel Bronson naesten at gmail.com
Thu Jan 11 00:05:09 EST 2007


On 1/10/07, Malcolm Wallace <Malcolm.Wallace at cs.york.ac.uk> wrote:
> "Samuel Bronson" <naesten at gmail.com> 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.


More information about the Haskell mailing list