[Haskell-cafe] Lazy IO and closing of file handles
donn at drizzle.com
Thu Mar 15 02:12:14 EDT 2007
Quoth dons at cse.unsw.edu.au (Donald Bruce Stewart):
| In fact, the (commented out code) for mmapFile :: FilePath -> IO ByteString
| is in Data.ByteString now. You can also provide munmap as the finaliser,
| and let the GC take care of that.
It does make more sense to unmap the string when it's the whole file,
of course, and I assume it would force the OS to free the memory, if
it makes any difference.
Is there any cost to GC that can be avoided if there's no finalizer?
I mean, in the present case you might generate many thousands of substrings
during analysis of the file, so in theory there's a lot less book-keeping
needed if there's nothing to do in the end anyway.
Donn Cave, donn at drizzle.com
More information about the Haskell-Cafe