
These things are always tricky to understand, which is why I recommend not using lazy I/O. File reading is not a pure operation: running out of file descriptors is a good counter-example.
Without saying wether I agree with lazy I/O or not, I suggest that this particular problem may also be due to the runtime implementation: If one tries to open a new file but the file descriptors are exhausted, the runtime system should first trigger a full GC because that might free up some descriptors -- but maybe GHC is already doing this? This brings me to another "issue". It would be nice if we can create foreign pointers with a resource estimate. That is, a foreign pointer to a bitmap might have a high resource estimate. This resource estimate can be used by the garbage collector to collect more aggressively if the "foreign" resources become filled. I haven't fleshed out a complete design yet, but it should be somehow possible to express that file-descriptors have a rather high resource estimate, as they run out after about 200 have been allocated. All the best, Daan.
Cheers, Simon _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell