[Haskell-cafe] Lazy IO and closing of file handles
Ketil Malde
Ketil.Malde at bccs.uib.no
Thu Mar 15 08:01:11 EDT 2007
Matthew Brecknell wrote:
> Ketil Malde:
>
>> Perhaps this is an esoteric way, but I think the nicest approach is to
>> parse into a strict structure. If you fully evaluate each Email (or
>> whatever structure you parse into), there will be no unevaluated thunks
>> linking to the file, and it will be closed.
>>
>
> Not necessarily so, since you are making assumptions about the
> timeliness of garbage collection.
Good point. I'd have hoped that the RTS would GC on file handle
exhaustion, but perhaps this is hard to do?
I think parsing input strictly is good practice anyway, since parsing is
often not very compute intensive, and tends to reduce the memory
required. At least, that is my experience.
-k
More information about the Haskell-Cafe
mailing list