> % cat > manyfiles.hs
> main :: IO ()
> main = do
>     readFile "manyfiles.hs"
>     main
> % ghc -o manyfiles manyfiles.hs
> % ./manyfiles 
> 
> Fail: resource exhausted
> Action: openFile
> Reason: process file table full
> File: manyfiles.hs

> In fact nhc98 behaves the same, but hugs seems to do better
> and just keeps opening and closing the file handles (in
> blocks of 37 apparently).

It is really a question of when the garbage collector runs.
Your example program is very small, so the GC does not run (and
therefore does not collect the unused handles) before the open file
table is filled.

With nhc98, if you run the program with a small heapsize to force
more frequent GC, it displays the behaviour you expect, e.g.

    nhc98 -o manyfile.hs -H2565         # 2565 bytes of heap
    ./manyfiles                         # does not terminate!

For this heapsize, strace shows that the program opens and closes
the file handles in groups of 229.

(Sadly, I don't think it is possible to run ghc-built programs in
such a small heap.)

Regards,
    Malcolm

_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to