[Haskell] Re: state of HaXml?

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Wed Jan 10 05:01:22 EST 2007

"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.


More information about the Haskell mailing list